Linux专业更名工具rename使用

WARNING(注意⚠️)

The renaming has no safeguards.  If the user has permission to rewrite file names,  the  command  will
perform  the action without any questions.  For example, the result can be quite drastic when the com‐
mand is run as root in the /lib directory.  Always make a backup before running  the  command,  unless
you truly know what you are doing.

语法格式

rename [options] expression replacement file.. 即:
rename 原字符串 新字符串 文件名

rename 实战

批量更改文件的后缀名,如下:

批量创建实验用文件

# touch {test1.txt,test2.txt,test3.txt}
# ll
总用量 0
-rw-r--r-- 1 root root 0 10月 30 16:58 test1.txt
-rw-r--r-- 1 root root 0 10月 30 16:58 test2.txt
-rw-r--r-- 1 root root 0 10月 30 16:58 test3.txt

批量更改文件后缀名

# rename "txt" "gif" *.txt