0

I want to change file names in a folder in a way like this:

previous form             new form
one-1      to           VAS-M0001-001
one-2      to           VAS-M0001-002
one-3      to           VAS-M0001-003
one-4      to           VAS-M0001-004

Can anyone please suggest me a good way to do that?

1

2 Answers 2

3

I would just use a simple loop:

for f in one-*; do mv one-$f VAS-M001-000$f; done

Of course, you can use printf to format the number better (if you have more than 9 files)

Sign up to request clarification or add additional context in comments.

Comments

1

rename has such a functionality

[username@hostname aa]$ touch one-1 one-2 one-3 one-4
[username@hostname aa]$ ls
one-1  one-2  one-3  one-4
[username@hostname aa]$ rename one- VAS-M0001-000 one*
[username@hostname aa]$ ls
VAS-M0001-0001  VAS-M0001-0002  VAS-M0001-0003  VAS-M0001-0004

1 Comment

syntax error at (user-supplied code) line 3, at EOF

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.