Renaming images in specific order

Solution 1:

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
done 

Solution 2:

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" 
done 

Solution 3:

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

Solution 4:

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.