1

I have about 200 files that are named like this:

01_-_Back_Alley_Uproar.avi
01_-_Bad_Luck_Cat.avi
01_-_Beep_Beep.avi
02_-_Broomstick_Bunny.avi
02_-_Bunker_Hill.avi

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.

2 Answers 2

1

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

s/^\d+_-_//

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

0

You can use the following command:

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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .