Tag Archives: CS based

Batch modification of file names on MAC Linux rename command line

[rename] [rename] [rename] [rename] [rename] [rename]

zsh: command not found: rename

So use Homebrew to install it first:

➜  ~ brew install rename

After that, you can directly use a simple one-line command to change the name of multiple files. The general format is as follows:

➜  ~ rename 's/old/new/' *.files 

Ex. :
Change the prefix of batch PNG files from ‘ic_’ to ‘ic_setting_’ :
(ic_launcher.png -> ic_setting_launcher.png)

➜  ~ rename 's/ic_/ic_setting_/' *.png 

Modify part names of batch files:
(ic_setting_launcher.png -> ic_launcher.png)

➜  ~ rename 's/_setting//' *.png 

Supplement:
You can also use :
to change the first five letters to XXXXX (note ^… It’s five.

for i in `ls`; do mv -f $i `echo $i | sed 's/^...../xxxxx/'`; done

Usage is almost the same, the rest is up to us to flexibly use.