Thursday, March 5, 2009

renaming all files in a directory to change spaces to underscores

$find . -depth|rename 's/\ /_/g'

thts why linux is linux

And just off the track: you can calculate time taken by any command using time command. This will tell time taken to rename all the files in the current folder.

$time find . -depth|rename 's/\ /_/g'

2 comments:

anotherboy said...

what here mean by rename 's/\ /_/g'

:(

alind sharma said...

1) rename is a command for renaming files.
2) s/\ /_/g is pretty standard thing. The main thing is between s/ and /g. It is replace '\ ' i.e. 'escaped space' i.e. space in filenames with '_'. Slaces in between are customary as per syntax.
3) Sorry for being sooooo.... late.