作者:matrix
被圍觀: 2,964 次
釋出時間:2019-02-22
分類:零零星星 |
一條評論 »
💡NOTICE:這是一個建立于 796 天前的主題,其中的資訊可能已經有所發展或是發生改變。
win上的打包的檔案丢到linux解壓發現中文的字首亂碼,本來mv指令到是可以修改 顧于檔案太多,發現用rename友善的多
需要将╬в╨┼═╝╞м_20180626102853.jpg修改還原為微信圖檔_20180626102853.jpg
執行操作
檔案數量有點多執行
指令$:rename 's/╬в╨┼═╝╞м(.*)/微信圖檔$1/' *
rename --help
Usage:
rename [ -h|-m|-V ] [ -v ] [ -n ] [ -f ] [ -e|-E *perlexpr*]*|*perlexpr*
[ *files* ]
Options:
-v, -verbose
Verbose: print names of files successfully renamed.
-n, -nono
No action: print names of files to be renamed, but don't rename.
-f, -force
Over write: allow existing files to be over-written.
-h, -help
Help: print SYNOPSIS and OPTIONS.
-m, -man
Manual: print manual page.
-V, -version
Version: show version number.
-e Expression: code to act on files name.
May be repeated to build up code (like "perl -e"). If no -e, the
first argument is used as code.
-E Statement: code to act on files name, as -e but terminated by
';'.
perlexpr表達式
perlexpr還可用于其他指令,如sed
perlexpr表達式形如:
Substitution替換
s / expr1 / expr2 / [gi]
/為分界符,可以使用其他任意字元為分界符
expr1,expr2都支援正則
expr1會被查找替換為expr2。
ig兩個字母分别為正則的比對模式:忽略大小寫和全局比對,否則預設換行為分界符。方括号[]包裹表示他們可不填。
Translation字元轉譯
類似于替換s,它可用于将一個字元串轉換為另一個字元串,即字元轉換。表達式如:y/charset1/charset2/
如:
轉換為小寫:rename 'y/A-Z/a-z/' *
添加txt字尾:rename 's/$/\.txt/' *
PEACE~
參考:
https://www.computerhope.com/unix/rename.htm
https://wangchujiang.com/linux-command/c/rename.html
https://blog.csdn.net/qq_37858386/article/details/78404001
http://bbs.chinaunix.net/thread-4119882-1-1.html