Multiple rename in bash

In case you are wondering how to rename multiple files in bash here is an idea:

for file in ?????*; do mv $file `echo $file | cut -c4-`; done

Whit this you can cut 4 characters from the beginning of the file names which are at least six characters long.

Btw, this will NOT work if you have spaces in your filenames, but to solve this you can issue the command below replacing spaces with underscores:

for file in *\ *; do mv $file ${file// /_}; done

Enjoy 😉

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s