0

I want to rename 200 files Actually each files is named liked this :

00001-abcd-efgg?g............. 00002-xcvb-vbnv?b............. 00003-cbvc-hugh?j............. 

Now I want to rename all this files like this :

001 002 003 ... 

So I need to remove the first 2 digit, and to remove also everything after the fifth digit. Warning : there's a " ? " in each file I want to rename.

2
  • 2
    That's nice... have you tried this at all yourself, or are you just wanting us to do your job for you? Commented Aug 17, 2012 at 14:48
  • 1
    See this: stackoverflow.com/questions/11990893/… Commented Aug 17, 2012 at 14:50

2 Answers 2

4
for f in * do mv "$f" "${f:2:3}" done 
Sign up to request clarification or add additional context in comments.

Comments

1

Use rename:

rename -nv 's,.*(\d{3}).*,$1,' * 

Output:

00001-abcd-efgg?g............. renamed as 001 00002-xcvb-vbnv?b............. renamed as 002 00003-cbvc-hugh?j............. renamed as 003 

Remove the n when you're satisfied with the output.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.