linux_rename命令用法


rename在man中的解釋為:

NAME
       rename - rename files

SYNOPSIS
       rename [options] expression replacement file...

DESCRIPTION
       rename will rename the specified files by replacing the first occurrence of expression in their name by replacement.

OPTIONS
       -v, --verbose
              Give visual feedback which files where renamed, if any.

       -V, --version
              Display version information and exit.

       -s, --symlink
              Peform rename on symlink target

       -h, --help
              Display help text and exit.

EXAMPLES
       Given the files foo1, ..., foo9, foo10, ..., foo278, the commands

              rename foo foo0 foo?
              rename foo foo0 foo??

       will turn them into foo001, ..., foo009, foo010, ..., foo278.  And

              rename .htm .html *.htm

       will fix the extension of your html files.

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 command is run as root in the /lib directory.  Always make a backup before running the command,  unless  you  truly
       know what you are doing.

SEE ALSO
       mmv(1), mv(1)

其參數為三個,而不是兩個

mv指令也可以更改文件名,但是只能一個一個更改 

rename命令提供了批量更改的渠道

用法如下:

比如一個文件夾下有如下文件

20190328. 20190329. 20190330. 20190331. 20190401. 20190402. 20190403. 20190404. 20190405. 20190406. 20190407. 20190408. 20190409.

我要把每個文件后面的“.”置換成“.txt”則只需執行如下命令

rename . .txt *.

這樣就 okl

“*”是通配符,還有“?”是代表一個字符

 

希望對大家有所幫助

以上

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM