I have about 200 files that are named like this:


and so on. I would like to rename them all to look like this:

Back Alley Uproar.avi
Bad Luck Cat.avi
Beep Beep.avi
Broomstick Bunny
Bunker Hill

and so on...

I need to use the command line as I am connected via ssh via winSCP from a windows box to get to my ubuntu server containing these files. Thanks in advance.


You can use the rename command, with appropriate regular expressions e.g.


for 'replace an initial sequence of digits followed by underscore hyphen underscore'; and

s/_/ /g

to replace underscores with spaces. So

rename -nv 's/^\d+_-_//;s/_/ /g' *.avi

The -n makes it run in test (dry run) mode - test it in your directory and if you are happy that it's doing the right thing, run it without the n


You can use the following command:

rename 's/[0-9]+_-_//; s/_/\ /g' *

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.