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: 

It's past my bedtime is using WP-Gravatar