Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have so many images more than 100 in a folder such as:


I want to rename all of them at once with ascending order numbers such as:


How can I do it using Ubuntu 10.04? Is there any terminal command to do it.

share|improve this question

I'm not sure how you want them numbered, but the following Perl script should do it (haven't tested it out, but should probably work):

    rename $_,($n++).".jpg";
share|improve this answer

Try the following in terminal:

 find . -name '*.jpg'| awk 'BEGIN{ i=0 } { printf "mv %s %d.jpg\n", $0, i++ }'| bash
share|improve this answer

Pure bash solution (bash version of o_o's perl script):

n=1; for f in ./*.jpg; do mv "$f" $n.jpg; n=$((n+1)); done
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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