Shell文件集體重命名的方法(Rename!)

 Linux文件單個重命名通常用mv命令,集體重命名不少人本身寫一個簡單腳本,可是其實Linux的rename命令能夠簡單實現絕大多數的重命名html

任務。man rename結果以下:ide

NAMEspa

       rename - Rename files.net

SYNOPSISorm

       rename from to file...htm

DESCRIPTIONblog

       rename will rename the specified files by replacing the first occurrence of from in their name by to.ci

       For example, given the files foo1, ..., foo9, foo10, ..., foo278, the commandsget

              rename foo foo0 foo?it

              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.

好比我有三個文件:

hs_ok_all_200911.txt

hs_ok_all_a.txt

hs_ok_all_b.txt

我須要將全部的hs_ok_all改成hs

則使用

rename hs_ok_all hs hs_ok_all_*

便可。

因此rename的第一個參數是要改的部分, 第二個參數是改後的結果,第三個參數是須要改的文件(含通配符)

轉自http://blog.csdn.net/skydreamer01/archive/2010/02/08/5298646.aspx

相關文章
相關標籤/搜索