[英]How to rename files useing Terminal
Can anyone recommend a good solution to recursively remove unwanted letters in file names remove 任何人都可以推荐一个好的解决方案,以递归方式删除文件名中不需要的字母
.720p.BluRay.x264-[YTS.AM]
For example: 例如:
Yellow Submarine (1968) [BluRay] [720p] [YTS.AM]
│ ├── www.YTS.AM.jpg
│ └── Yellow.Submarine.1968.720p.BluRay.x264-[YTS.AM].mp4
├── You Might Be The Killer (2018) [BluRay] [720p] [YTS.AM]
│ ├── www.YTS.AM.jpg
│ └── You.Might.Be.The.Killer.2018.720p.BluRay.x264-[YTS.AM].mp4
├── Your Name (2016) [BluRay] [720p] [YTS.AM]
│ ├── www.YTS.AM.jpg
│ └── Your.Name.2016.720p.BluRay.x264-[YTS.AM].mp4
becomes: 变为:
Yellow Submarine (1968) [BluRay] [720p] [YTS.AM]
│ ├── www.YTS.AM.jpg
│ └── Yellow.Submarine.1968.mp4
├── You Might Be The Killer (2018) [BluRay] [720p] [YTS.AM]
│ ├── www.YTS.AM.jpg
│ └── You.Might.Be.The.Killer.2018.mp4
├── Your Name (2016) [BluRay] [720p] [YTS.AM]
│ ├── www.YTS.AM.jpg
│ └── Your.Name.2016.mp4
Since the string being removed appears to be the same for each file then you can use find
and rename
to solve this: 由于要删除的字符串对于每个文件而言似乎都是相同的,因此您可以使用
find
和rename
来解决此问题:
find . -type f -exec rename 's/\.720p\.BluRay\.x264\-\[YTS\.AM\]//' '{}' \;
Run that in whatever the base directory is that holds these folders and it should clean the files up. 在包含这些文件夹的基本目录中运行该文件,它应该清理文件。
To test first you can use the -n
flag on that rename command to see what it will do if you allow it to act (without the -n
flag): 要首先进行测试,可以在该重命名命令上使用
-n
标志来查看如果允许它执行操作(不带-n
标志)时将执行的操作:
find . -type f -exec rename -n 's/\.720p\.BluRay\.x264\-\[YTS\.AM\]//' '{}' \;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.