Enter Rename+[enter directly in the terminal] to see the format of the command:
Earlier versions of Rename were in the C language version, and today the new Ubuntu features a more powerful version of Perl.
[-v][-n][-f][filenames]-v(verbose)打印被成功重命名的文件-n(no-act)只显示将被重命名的文件,而非实际进行重命名操作-f(force)覆盖已经存在的文件perlexprPerl语言格式的正则表达式files需要被替换的文件(比如*.c、*.h),如果没给出文件名,将从标准输入读
Commonly used parameters are -n
, you can first use the-n parameter to a small part of the picture to test, each execution of the command will be in the terminal the effect listed, and so on to ensure that no problem after the -n
parameters, and then all the data unified processing.
This application is to batch rename a batch of picture files (own picture data, as Caffe training and test data use)
It was all in this format:
(1). jpg
(2). jpg
.....
To change to:
Test_001.jpg
Test_002.jpg
......
Use a more stupid way: first to remove the parentheses, and then unified format (assuming that the picture file is stored in the terminal open the current directory location)
1. Remove Brackets
‘s/[()]//g‘ *.jpg解释:-n直接打印结果在终端中而非实际执行引号中是perl的正则表达式,用来匹配和替换,s代表substitution,替换的意思[()]代表匹配[]中的内容//两个斜杠之间是空代表替换为空的内容,相当于删除g代表全部匹配,不加g的话默认只会匹配一个括号
The effect here is similar, is the file name in the underscore and the number 3, look at the image of the effect should be clear:
2. Continue renaming to the desired format
rename‘s/^/test_/‘*.jpg解释:s-替换^-在文件名称开头加字符test_-将名称前面添加上test_
The effect is as follows:
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
Rename commands and batch renaming in Ubuntu