
7

使用rename批量重命名文件
source link: https://www.lujun9972.win/blog/2018/12/07/%E4%BD%BF%E7%94%A8rename%E6%89%B9%E9%87%8F%E9%87%8D%E5%91%BD%E5%90%8D%E6%96%87%E4%BB%B6/index.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

使用rename批量重命名文件
在linux上我们一般用 mv
命令来对文件进行重命名操作,但是 mv
一次只能对一个文件进行重命名,对批量文件进行重命名就比较麻烦了。
一直以来我都是写一段shell循环或者跟 xargs
配合来进行批量文件的重命名,直到今天发现linux有一个 rename
命令可以很方便地进行批量文件重命名。
rename的语法超级简单:
rename ${expression} ${replacement} ${files}...
它会对 files
中的所有文件进行重命名,方法是将名字中第一次出现 expression
的地方替换成 replacement
.
比如下面命令会将所有 .htm
文件重命名为 .html
文件:
rename .htm .html *.htm
再比如下面命令会把文件名中所有的 prefix_
前缀去掉:
rename "prefix_" "" prefix_*
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK