Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Click here to return to the 'removing/replacing spaces in filenames.' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
removing/replacing spaces in filenames.
Authored by: jhary on Mar 20, '03 12:16:01PM

just a one liner but say you have a bunch of mp3 files with spaces in their names and you wanted to replace the spaces with _ you can do
for file in *.mp3 ;do mv $file `echo $file | perl -p -e "s/\s+/_/g"` ;done

(this actualy replaces any number of spaces with one _ )
no backups though so make one before you try if youre worried. oh and it adds a _ at the end but thats easily fixed by doing
mv *.mp3_ *.mp3

[ Reply to This | # ]