Can I renumber my images?

Renumbering images is a common need for getting images to sort in the correct order. For example consider the following list:

  • image1
  • image10
  • image100
  • image101
  • image102
  • image11
  • image12
  • image2

DF Studio's Rename Images tool provides the ability to use Regular Expressions to find/replace portions of a name using a pattern. In the list shown above, the problem is that some names need one zero added, but some need two. So, this must be done in two steps.

First, find all of the single-digit numbers:

Find: image(\d)$
Replace: image00$1

This will rename image1 to image001 and image2 to image002. 

Then, replace the two-digit numbers:

Find: image(\d\d)$
Replace: image0$1

That will rename image10, image11, image12 to image010, image011, image012, making the resulting list:

  • image001
  • image002
  • image010
  • image011
  • image012
  • image100
  • image101
  • image102

So how to the find and replace patterns used above work? Without getting too much into the specifics of regular expressions, here is what is being said in the first example: find images that start with "image" followed by a single digit. The parenthesis in (\d) say to "capture" the information to use in the replace. The $ stands for "end of line" or the end of the name. In the replace part, the image name is replaced with "image" followed by two zeros, followed by the part captured in the find. ($1 is the first captured item. Multiple items can be captured and re-used using $1, $2, $3, etc.)

The Rename Images tool provides a Preview New Names button that makes it easy to test your find and replace pattern before committing your changes.



 See also: What is a regular expression?

Feedback and Knowledge Base