mat*_*olf 6 command-line batch-rename
我在原始命名方案中有大约 2000 个文件。
我需要将它们全部取出,将前 4 个字符移动到扩展名之前的文件名末尾,然后在前 4 个字符之前添加一个空格。
基本上,来自:
0123 [UNKNOWN] (Final Fantasy 9) headshot of Freya Crescent {sketch} (ORIGINAL).jpg
Run Code Online (Sandbox Code Playgroud)
到
[UNKNOWN] (Final Fantasy 9) headshot of Freya Crescent {sketch} (ORIGINAL) 0123.jpg
Run Code Online (Sandbox Code Playgroud)
这应该有效:
rename -n 's/^([0-9]+) (.*)\.jpg/$2 $1.jpg/' /path/to/files/*.jpg
Run Code Online (Sandbox Code Playgroud)
样本:
0324 [UNKNOWN] (Final Fantasy 9) headshot of Freya Crescent {sketch} (ORIGINAL).txt
0123 [UNKNOWN] (Final Fantasy 9) headshot of Freya Crescent {sketch} (ORIGINAL).txt
0124 [UNKNOWN] (Final Fantasy 9) headshot of Freya Crescent {sketch} (ORIGINAL).txt
Run Code Online (Sandbox Code Playgroud)
结果:
rename(0123 [UNKNOWN] (Final Fantasy 9) headshot of Freya Crescent {sketch} (ORIGINAL).txt, [UNKNOWN] (Final Fantasy 9) headshot of Freya Crescent {sketch} (ORIGINAL) 0123.txt)
rename(0124 [UNKNOWN] (Final Fantasy 9) headshot of Freya Crescent {sketch} (ORIGINAL).txt, [UNKNOWN] (Final Fantasy 9) headshot of Freya Crescent {sketch} (ORIGINAL) 0124.txt)
rename(0324 [UNKNOWN] (Final Fantasy 9) headshot of Freya Crescent {sketch} (ORIGINAL).txt, [UNKNOWN] (Final Fantasy 9) headshot of Freya Crescent {sketch} (ORIGINAL) 0324.txt)
Run Code Online (Sandbox Code Playgroud)
注意:用.txt文件测试也适用于 jpg 文件名
信息:
([0-9]+): 选择前面的数字。
(.*): 选择其他所有东西,直到文件扩展名。
$2 $1.txt: 返回捕获的组,返回的组numbers放置在靠近文件扩展名的位置,jpg并在数字前添加一个空格。
-n: 在不更改文件名的情况下运行,以便我们查看更改的文件以及更改的名称,删除它以重命名文件。
| 归档时间: |
|
| 查看次数: |
2198 次 |
| 最近记录: |