PDA

View Full Version : Batch file rename



DaMasta
January 2nd, 2006, 11:48 AM
I need to rename all my mp3s with underscores instead of spaces. I have this script which will rename all the files ending in mp3 from spaces to underscores within a directory. I have about 300 albums though so doing it directory by directory is very tedious. How can I change this script to do it recursively? Thanks.


for i in $(ls -1 *)
do
rename 's/\ /_/' *.$1
done

meborc
January 2nd, 2006, 12:03 PM
maybe that helps: http://ubuntuforums.org/archive/index.php/t-98147.html

toojays
January 2nd, 2006, 12:06 PM
Use the 'find' utility:
find . -type f -execdir rename 's/\ /_/' '{}' ';'

DaMasta
January 2nd, 2006, 12:52 PM
Thanks guys.