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 😉

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.