Rename large list of files by removing just one character

Sometimes, we have a large collection of files e.g mp3 files that plays fine in a computer, but fails to copy to an external devices like a mobile phone, because of weird file naming. One of such cases happened to me, where all the files in a directory had pipe character (|) on them.

Those files would play fine on a computer, but failed to copy to a phone. Therefor,e I had to create following script to rename all those files, just by removing the pipe character(|). Here is the script (rename.sh).

for file in *.mp3
do
 rename 's/\|//' "$file"
done

I hope it helps someone.

 

About these ads

Leave a comment

Filed under Uncategorized

Leave a Reply

Please log in using one of these methods to post your comment:

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