简体   繁体   中英

Rename files recursively Linux

In Linux, I have a folder with files of the following names:

Abaraham test.txt 
Jacoobs_resulr.txt
Brabraim's test.txt 
....
Jamine.txt '

May I know how could I rename the files recursively to file1.txt ... file20.txt?

这将做:

cnt=0; for f in *; do [[ -f "$f" ]] && mv "$f" "file$f$cnt.txt" && cnt=$[cnt + 1]; done

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM