This is my problem: I have a folder with 500 images named:


and so on..

I copied that folder and now I need to rename those same pictures from 501 to 1000 but in order like this:

1.jpg  becomes    501.jpg
2.jpg  becomes    502.jpg
3.jpg  becomes    503.jpg          

When I use my standard renaming command:

i=501;for img in $(find . -iname '*.jpg'); do echo -n "Converting $img"; mv $img $i.jpg  && echo $i && ((i++)); done

It orders images from 501 to 1000 but they are all scattered:

23.jpg becomes 501.jpg,    
66.jpg becomes 502.jpg 

(they are in right order, but it mixes them up)

I know it's probably one command I'm missing...

  • Use 2 variables i and j mv $i.jpg $j.jpg and increment your variables.
    – Panther
    Commented Aug 25, 2017 at 17:12
  • thank you, hope you'll figure it out. I searched but didn't find the answer..
    – Painkiller
    Commented Aug 25, 2017 at 17:12
  • Just curious, the original names, in what range are they? Should the original number just be renamed + 500? Commented Aug 25, 2017 at 17:15
  • Yes Jacob you +500. I am trying to write what bodhi told me but I am not so good in lnux, I killed my self to write the rename command above :D
    – Painkiller
    Commented Aug 25, 2017 at 17:17
  • My poor laptop is heavily occupied atm, but if no satisfying answer comes up (which I doubt :) ) and if you won't manage, I'll post a tiny python script tonight. Commented Aug 25, 2017 at 17:22

5 Answers 5


The find command finds files in 'directory' order (23.jpg, 66.jpg, ...). you could put a |sort after the find.

But your methods are overcomplex.

for i in $( seq 1 500 ) ; do
    j=$(( $i + 500 ))
    mv $i.jpg $j.jpg
  • 3
    for i in {1..500}; do ... would have bee easier. Commented Aug 26, 2017 at 13:40

With rename command.

rename -n 's/^(\d+)/sprintf("%d",$1+500)/e' *.jpg

Or in pure bash and using shell parameter expansion.

for FILE in *.jpg; do
    mv "$FILE" "$(( ${FILE%.jpg}+500 )).jpg" 

Try Thunar, which is the default file manager for Xfce. It is very lightweight and comes with a handy bulk renaming tool. You can install Thunar by running the following command in Terminal:

sudo apt-get install thunar

You'll probably be able to install from Ubuntu Software too.

How to use the utility

  1. Once you've installed Thunar, launch the Bulk Rename utility.
  2. Click on the + icon and add the files you want to rename in the proper order.
  3. Click on the drop-down box just below the list of selected files and select Numbering. Click on the box next to it and select Name Only.
  4. In the "Start With:" box enter 501, leave the "Text:" box empty. You should see the preview of the changes in the New Name column.
  5. To apply the changes click on the Rename Files button.

Besides Numbering this utility supports the following actions:

  • Insert Date / Time
  • Insert / Overwrite
  • Remove Characters
  • Search & Replace
  • Uppercase / Lowercase
  • Thanks man you're the MVP! I only have to add that I also needed to change Text format to: Text - Number. (just in case anyone else use this)
    – Painkiller
    Commented Aug 25, 2017 at 17:30
  • 2
    To Switch fm to... perform a simple task seems overkill to me. Writing a simple nautilus script extension takes less time then switching fm. Commented Aug 25, 2017 at 17:40
  • 1
    @JacobVlijm I'm using Thunar just for the bulk rename tool along with Nautilus. Thunar is pretty light and doesn't seem to cause any conflict with Nautilus or other file managers.
    – pomsky
    Commented Aug 25, 2017 at 17:45
  • 4
    If you don't want a second file manager, pyrenamer works perfectly and is what I use for bunk renames when I want a GUI to compare before/after output. Commented Aug 25, 2017 at 17:48

If I've understood what you are asking correctly, I think you can do it using the default rename tool:

rename 's/^(\d+)/sprintf("%d",$1+500)/e' *.jpg -vn

You should remove the -vn (verbose - no action) switch after testing, to make the change effective.

  • How can one install this tool in Ubuntu? by default rename is linked to prename(1) from the perl package which doesn't support all these command-line options. Commented Aug 26, 2017 at 13:45
  • @DavidFoerster You may be right. I couldn't find a current installation link (I haven't used it since about 2014). With the default rename tool, I think the regex expression should be 's/^(\d+)/sprintf("%d",$1+500)/e'. I'll update my answer accordingly. Thanks. Commented Aug 26, 2017 at 14:11
  • 1
    Your answer is now a duplicate of AFSHIN’s. Commented Aug 26, 2017 at 14:22
  • @DavidFoerster Sorry, what answer? The only other answers I can see are by pomsky & waltinator. Neither use rename (either version). Commented Aug 26, 2017 at 14:26
  • The direct link to the answer I mean is included in my previous comment. Commented Aug 26, 2017 at 14:28

Another way of achieving this with just shell command

count=1;for i in ls; do mv $i CN$((count++)).${i##*.}; done

You must log in to answer this question.

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