Tag Archives: The command line

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.

Error: EACCES: permission denied, access ‘/usr/local/lib/node_modules’ npm ERR! at Error (native)

Use the command line to keep this Error similar to: Error: EACCES: Permission Denied, Access ‘/usr/local/lib/node_modules’ NPM ERR! at Error (native)

Reason: No administrator rights were obtained while executing command line commands

Solution: Simply prefix the command with sudo. Then enter the computer administrator password operation can be completed.