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

Click here to return to the 'Oops, I goofed on that one ...' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Oops, I goofed on that one ...
Authored by: elfkinz on May 20, '02 12:37:00PM

Somehow I lost a few \s on the last posting ... What I meant to say was:

Try adding sed 's/\ /\\\ /g' after the ls and before the awk:

ls foo*.jpg | sed 's/\ /\\\ /g' | awk '{print("mv "$1" "$1)}' | sed 's/foo/bar/2'

This should take care of the spaces ... the only problem I can't figure out yet is removing spaces from the file names.

[ Reply to This | # ]
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 | # ]