SunlitGreen - Free Digital Photo Editing Programs
Home > Products > SunlitGreen BatchBlitz > Tips and Tricks > Batch Rename Files Using Regular Expressions

Batch Rename Files Using Regular Expressions

At times, when you batch rename image files, you may want to keep part of their old names.

This article provides a step-by-step guide to doing such renaming.




At times, when you batch rename image files, you may want to keep part of their old names.

For example, suppose we have some images, each including a number in its name. See below:


Here we'd like to batch rename these files so that the new names still contain those numbers. Besides, the new names must also contain the camera make info. So the image list may be something like:


The next section provides a step-by-step guide to doing this renaming.

To Batch Rename Files using Regular Expressions

In BatchBlitz, the Rename File action enables you to batch rename your image files.

Choose File > New to create a new task, then follow the below steps:

Step 1: Select source images.

In Source view, select your image files into the Source Images list. In this example, these files all have a number in their names. See below:


Step 2: Specify where to store the renamed photos.

In Output view, specify a folder for the renamed files.

By selecting the first radio option (as shown in the above image), you can make sure all original files remain intact after renaming.

You may want to select the second radio option instead if you prefer in-place renaming.

Step 3: Add a Rename File action.

In Actions view, click button on the toolbar above the actions list. In the shown "Add Actions" dialog, check item "Rename File" and press OK.

You can also double-click the empty area of the actions list to invoke this dialog.

Now the actions list has a "Rename File" action. Make sure to activate it by checking the Active option. See below:


Step 4: Customize this Rename File action.

To edit the added action, just double-click its icon or label. This invokes the "Action Properties" dialog for the Rename File action.

Check option "Use this pattern", then (1) set the target pattern to $1_$EXIF_MAKE; (2) set the source pattern to (\d+). See below:

Note that the source pattern (\d+) matches and captures a digital number. The Rename File action will search the title part of the original file name for this pattern.

If a number is found in the original file name's title part, it is captured and can be back-referenced as $1. So we set our target pattern to $1_$EXIF_MAKE, where $EXIF_MAKE is a macro representing the camera make info of the photo being processed.

Click OK to close the "Action Properties" dialog.

Step 5: Start the task.

Now we've got everything ready and we can start the task. Just click button on the main toolbar.

Want to Learn More?

For more information on the Rename File action, macros and regular expressions, see the BatchBlitz online documentation.