I want to change file names in a folder in a way like this:
previous form new form
one-1 to VAS-M0001-001
one-2 to VAS-M0001-002
one-3 to VAS-M0001-003
one-4 to VAS-M0001-004
Can anyone please suggest me a good way to do that?
I would just use a simple loop:
for f in one-*; do mv one-$f VAS-M001-000$f; done
Of course, you can use printf to format the number better (if you have more than 9 files)
rename
has such a functionality
[username@hostname aa]$ touch one-1 one-2 one-3 one-4
[username@hostname aa]$ ls
one-1 one-2 one-3 one-4
[username@hostname aa]$ rename one- VAS-M0001-000 one*
[username@hostname aa]$ ls
VAS-M0001-0001 VAS-M0001-0002 VAS-M0001-0003 VAS-M0001-0004
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.