Batch rename files with spaces in linux/bash

A reminder for myself how to batch rename files with spaces in bash.

This is how i rename files with space to have underscores instead. DO NOT blame me if this commando erases all your files :) I found several examples how to do this when googling but they all failed. Some of them did nothing and some erased half my filenames. SO IF YOU USE THIS, PLEASE TRY IT IN A FOLDER WITHOUT IMPORTANT FILES FIRST.

1
for f in *' '*; do mv "$f" "`echo $f | sed -e 's/ /_/g'`"; done

Cheers!

Posted in Linux, Note to self, Operatingsystem at October 20th, 2010. Trackback URI: trackback Tags: , , Written by: 

No Responses to “Batch rename files with spaces in linux/bash”

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

pastbedti.me is using WP-Gravatar