in technology

I had a file renaming problem, where I wanted to remove the spaces from about a thousand files and folders for easier batch handling (I want to convert my ebook science fiction collection into .epub for reading on my iPod). The solution turned out to be:

for file n *; do mv "$file" "`echo $file | sed -e 's/\ /_/g'`"; done

“For every file here, please move the file while replacing spaces with underscores.” I take every file name and I use echo in combination with sed to perform a batch rename.

And not:

for rar in *.rar; do mv $rar $(echo $rar | sed 's,[ ]*,_,g'); done

“For every file here, please add an underscore before and after each character in the filename.”

The first removes inconvenience spaces. The second messes your files up. Whoops.

in technology

Mark Grealish

Dashing brigand, handsome rapscallion, father, crazy cat lady and the world's greatest lover and liar, living in Galway, Ireland.

Have your own say on 'Ooh:':

Have your say:

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>