我需要重命名如下:
file_001_loremipsum.png
file_002_dolor.png
file_003_sit.png
file_004_amet.png
file_105_randomness.png转到
upl_loremipsum.png
upl_dolor.png
upl_sit.png
upl_amet.png
upl_randomness.png如何通过简单的终端命令行来实现这一点?
发布于 2013-04-19 10:19:06
以上示例的解决方案,使用重命名:
rename -v -n 's/file_\d{1,3}/upl/' file_*.png用法:
rename [options] [Perl regex search/replace expression] [files]来自man rename:
-v, --verbose
Verbose: print names of files successfully renamed.
-n, --no-act
No Action: show what files would have been renamed.重命名可以使用regex作为参数。
我们要看的是单引号'之间的内容。您可以将regex放在由/分隔的位置。
公式:s/(1)/(2)/,其中(1) =搜索模式,(2) =替换模式。
因此,使你熟悉正则表达式,并享受基于模式的批处理文件重命名!
https://askubuntu.com/questions/283145
复制相似问题