How to Batch Rename Photos but Keep Same Numbers

Abstract: Batch rename photos with PowerToys or Terminal to preserve original numerical sequences while adding prefixes or suffixes.

Created: 2026-10-13 by

You can batch rename photos while preserving their original numerical sequences by using dedicated file management tools like PowerToys on Windows or Terminal commands on macOS, rather than relying on basic operating system features that often reset counters. This approach ensures that files named IMG_001.jpg, IMG_002.jpg, and so on, retain their specific numeric identifiers even after you add prefixes or suffixes to the text portion of the filename.

The Challenge with Standard Operating Systems

When users attempt to rename multiple images simultaneously through the standard graphical interface of Windows Explorer or macOS Finder, they frequently encounter a frustrating limitation. Most basic file managers do not support complex pattern matching that allows for the insertion of text while keeping existing numbers intact. Instead, they typically apply a simple sequential counter to every selected file. For example, if you select ten photos and try to rename them all at once in Windows, the system might rename them to New Name 1.jpg, New Name 2.jpg, up to New Name 10.jpg. This completely erases the original date-based or camera-generated numbering sequence, which is often crucial for organizing large volumes of photography work. The core issue lies in how these default tools handle string manipulation. They treat the entire filename as a single block or replace only the extension, but they lack the logic to parse "Prefix + OriginalNumber + Suffix". To solve this, you need software that supports regular expressions or advanced pattern variables. This is where specialized utilities become essential for maintaining data integrity during bulk operations.

Solution for Windows Users: Microsoft PowerToys

For Windows users, the most robust and free solution is Microsoft PowerToys, specifically its PowerRename utility. This tool integrates directly into the right-click context menu and offers powerful regex capabilities that allow you to keep your numbering scheme perfectly intact. First, ensure you have installed Microsoft PowerToys from the official Microsoft Store or GitHub repository. Once installed, navigate to the folder containing your photos. Select all the images you wish to rename by pressing Ctrl+A or dragging your mouse over them. Right-click on the selection and choose PowerRename from the context menu. A dialog box will appear with two main fields: Find what and Replace with. To preserve the numbers, you must use a capture group. In the Find what field, enter the pattern that matches the start of your filename but excludes the number. If your files are named DSC_0001.JPG, you might want to find DSC_. However, a more flexible approach is to match the whole name and reconstruct it. Enter the following in the Find what box:
(.*)\.jpg
This regular expression captures everything before the extension into group one. In the Replace with box, you can now insert your new prefix followed by the captured group. For instance, if you want to add the word "Vacation" before the existing number, enter:
Vacation $1.jpg
Notice that we are appending .jpg again because the dot was part of the non-captured remainder. If you want to be safer with extensions, you can use separate groups for the name and extension. The key is understanding that $1 refers to the first set of parentheses in your find pattern. After entering these values, click Preview to verify that DSC_0001.JPG becomes Vacation DSC_0001.jpg without changing the digits. If the preview looks correct, click Apply. This method works for thousands of files instantly and preserves the exact numeric string you started with. If you are dealing with corrupted files during this process, it may be helpful to check our guide on JPEG Corrupted File Fixing to ensure your source images are readable before renaming.

Solution for macOS Users: Terminal and Automator

Mac users have access to powerful command-line tools that can achieve the same result without installing third-party applications. The rename utility (often available via Homebrew) or a simple Bash loop can manipulate filenames precisely. Open the Terminal application and navigate to your photo directory using the cd command. A common scenario is adding a prefix to all JPEG files while keeping the original name. You can use a for loop to iterate through each file. The syntax relies on parameter expansion to strip extensions and reassemble names. Run the following command structure carefully:
for f in *.JPG; do mv "$f" "prefix_${f}"; done
In this command, *.JPG selects all files ending in JPG. The variable ${f} holds the original filename, including its number. By placing prefix_ before ${f}, you are simply prepending text. The original number remains untouched because you are not parsing out the number; you are just attaching new text to the front of the existing string. If you need to insert text *after* the number but before the extension, the logic is slightly more complex. You would need to use sed or a more advanced script. However, for most photographers, prepending a campaign name or date code is sufficient. Always test your command by replacing mv with echo mv first. This prints the command to the screen instead of executing it, allowing you to verify that the output filenames look correct before you permanently alter your files.

Handling Edge Cases and Verification

Regardless of the tool you use, there are critical steps to prevent data loss. Always create a backup copy of your photos before running any batch rename operation. While PowerToys and Terminal scripts are generally safe, a typo in your regular expression can lead to unexpected results, such as duplicating extensions (e.g., name.jpg.jpg) or overwriting existing files. Check for spaces in your original filenames. Some older cameras generate filenames with spaces, which can break command-line scripts if quotes are not used properly. Ensure your quoting strategy is consistent. Additionally, consider the sort order. If your photos are named IMG_001.jpg through IMG_010.jpg, alphabetical sorting works fine. But if you have IMG_1.jpg and IMG_10.jpg, lexicographical sorting will place IMG_10.jpg between IMG_1.jpg and IMG_2.jpg. Preserving the leading zeros in your numbers is vital for correct chronological ordering in gallery viewers. If you find that your renamed files are not displaying correctly in certain applications, check our article on Why this photo cannot be opened on any browser except Google Chrome? to rule out metadata issues unrelated to the filename itself.

Frequently Asked Questions

Will renaming photos change their EXIF metadata?

No, renaming a file does not alter the internal EXIF data embedded within the image, such as the date taken, camera model, or GPS coordinates. The metadata is stored inside the file binary, independent of the filename. However, some software libraries may struggle to read metadata if the file path contains special characters or if the extension is mismatched.

Can I use this method to remove numbers entirely?

Yes, you can use regular expressions to strip numbers. In PowerToys, you could find a pattern like \d+ (which matches one or more digits) and replace it with nothing. Be cautious, as this might leave gaps in your sequence (e.g., jumping from 1 to 3). It is usually better to keep the numbers for archival purposes.

What happens if I accidentally overwrite a file during batch rename?

If two different source files resolve to the same target filename during the rename process, the operation will fail or overwrite the first file with the second, depending on the tool's settings. Always use the Preview function in PowerToys or echo the commands in Terminal to ensure no naming collisions exist before applying changes.

Does this work for RAW files as well?

Absolutely. These methods work on any file type, including CR2, NEF, ARW, and DNG. Just ensure your file extension filter matches your raw format. For example, change *.jpg to *.CR2 in your commands or patterns. The logic for preserving numbers remains identical regardless of the file container.

Is there a risk of breaking links to my photos?

If you have hard-coded paths to these images in other documents, websites, or database records, renaming them will break those links. However, if you are only referencing them by relative path within a local project or portfolio, the links will update automatically if your software uses dynamic path resolution. Always check external references before bulk renaming.

Latest News

How to Display Output of xterm Command in Terminal Screen using Cron

Resolve the inability to display xterm output in a terminal screen from cron by redirecting logs or using wall instead of insecure X11 workarounds.

Read More
Expose Local Server on VPS Preserving Real Client IPs (OS Level)

Resolve VPS logging showing only gateway IPs by configuring reverse proxies to forward real client addresses via X-Forwarded-For headers.

Read More
How to Clear Recent Files History in Linux without Deleting Actual Files?

Clear recent files history in Linux by deleting ~/.local/share/recently-used.xbel without removing the actual files.

Read More
Best HDD Copy Strategy: Manually Syncing and Rewriting Scratch

Resolve data drift between two 4TB hard drives by using rsync with the --delete flag to manually sync and rewrite scratch data for an exact mirror.

Read More
Understanding Bash Prompt Abbreviations: An Overview

Resolve repetitive typing errors by creating and persisting Bash aliases in the .bashrc file for improved command-line efficiency.

Read More
Free Tools and Methods to Log Real-Time Performance Details in Task Manager

Log real-time CPU and memory metrics to CSV files using Windows Performance Monitor Data Collector Sets to troubleshoot system slowness.

Read More
Contact Qatar Airways Customer Service: Phone Number, Help Center, and More

Resolve urgent Qatar Airways reservation issues like flight changes and baggage claims using the US phone number +1801-855-5905 or online self-service tools.

Read More
Windows 11: Alt Codes Displaying Wrong Characters - Solutions

Resolve Windows 11 Alt codes showing wrong characters by verifying the US keyboard layout and enabling Num Lock.

Read More
Run Programs with Elevated Privileges: A Comprehensive Guide

Eliminates the need to type sudo for frequent administrative tasks by configuring .bashrc aliases or functions.

Read More
Dynamically Changing Dates in Excel Formulas Using Cells

Eliminate manual date updates in Excel by using cell references to create dynamic formulas that automatically adjust calculations when input dates change.

Read More
Granting Edit Access to a Specific Excel Sheet in an Office 365 User Email ID-Based Login

Excel Online lacks native sheet-level permissions, so users must split workbooks or use worksheet protection to isolate edit access for specific tabs.

Read More
Creating Network Load on Local Wi-Fi from One PC

Generate sustained Wi-Fi bandwidth load from a single PC using a VM SFTP server to test router stability and throughput.

Read More
Changing the Default Editor for Batch Files in Windows 11's File Explorer

Resolve the issue of batch files opening in Notepad by changing the default editor to a preferred application like VS Code.

Read More
Gain WiFi Connection Minutes Before Losing it by Changing MAC Address

Bypass MAC address filtering to restore WiFi connectivity temporarily when a device is blocked by network administrators.

Read More
Photos Folders Turned Black: Troubleshooting Picture Applications on Windows

Resolve black screens in Windows Photos by resetting the app, updating graphics drivers, and repairing system files.

Read More
Troubleshooting High CPU Temperature Values: A Step-by-Step Guide

Resolve high CPU temperatures and thermal throttling by monitoring with Speedfan, cleaning dust from cooling components, and replacing degraded thermal paste.

Read More
Make cURL establish TLS connection with CA unknown

Resolve cURL TLS connection failures with unknown or self-signed certificates by using the --insecure flag to bypass CA validation.

Read More
Troubleshooting Incorrect Network Metrics Values in Grafana, Prometheus, InfluxDB, and Telegraf

Fix incorrect network metrics in Grafana, Prometheus, InfluxDB, and Telegraf by verifying interface selection, resolving unit mismatches, and handling counter resets.

Read More
Start Another Terminal Window (cmd.exe) Windows Repair/Troubleshoot

Provides step-by-step instructions to access the Windows Command Prompt via bootable media for advanced system repair and troubleshooting.

Read More
Thinkpad P1 Gen 6: Sudden Thunderbolt 3 Dock USB-C Charging Stopped Working

Resolve sudden Thunderbolt 3 dock USB-C charging and internet failure on ThinkPad P1 Gen 6 by updating firmware, resetting the dock, and adjusting power settings.

Read More
ASUS Windows 11 Laptop: Internet Connection Issue with Hotspot

Resolve ASUS Windows 11 laptop spinning wheel issue when connecting to mobile hotspot by resetting network stack, disabling IPv6, and adjusting power settings.

Read More
Developing iOS Project with Firebase: Logging in and Sending Push Notifications

Integrates Firebase to enable secure user authentication and push notifications in iOS applications.

Read More
Troubleshooting Bash Script with Suspected Issues of Spaces, Dashes, Filenames and Quoting

Resolve Bash script failures caused by word splitting, globbing, and special characters in filenames by applying proper quoting techniques.

Read More
Populating OneDrive Folder for Local Backup without Affecting Remote Files

Prevent OneDrive from deleting remote files during Windows reinstallation by unlinking the account or using symbolic links to isolate local data.

Read More
Force First Frame as Keyframe Without Re-encoding: A Quick Solution

Resolve inaccurate seeking and playback glitches by re-encoding video to ensure the first frame is a valid keyframe.

Read More
Find Information in Database Using WSL (Ubuntu) on Windows-10

Resolve database connection issues from WSL Ubuntu on Windows 10 by configuring client tools and network access to query remote or local servers.

Read More
Configuring a New Router with Different Networks: One Family, One Guest

Resolve IP conflicts and isolate guest traffic by configuring a second router with a distinct subnet via its WAN port.

Read More
Quickly Open Multiple Stock Websites with a Single Command

Solve the problem of manually opening multiple stock research websites by creating a single command to launch them simultaneously on Windows, macOS, or Linux.

Read More
Improved Adobe Acrobat Search Experience: Access Advanced Search with Ease

Access advanced search filters like case sensitivity and regex in Adobe Acrobat by clicking More Options in the Find bar.

Read More
Port Forwarding VM via OpenVPN: A Comprehensive Guide

Configure OpenVPN server and iptables to forward specific ports from VPN clients to a virtual machine's internal IP address.

Read More
Understanding Partitions in the 1980s: A Look Back at MS-DOS and Master Boot Record

Explains how the Master Boot Record and partition table enabled MS-DOS to manage multiple disk volumes on a single physical drive.

Read More
Windows 10 Enterprise: Keyboard Not Detected in Managed Organization with Admin Privileges

Resolve Windows 10 Enterprise keyboard detection failures caused by Group Policy restrictions, driver corruption, or USB enumeration errors.

Read More
Can't Find x86_64 Versions of Applications on MacOS arm64 (M1)

Resolve missing x86_64 app issues on M1 Macs by installing Rosetta 2 and reinstalling apps as universal binaries.

Read More
How to Hide Installation Source for an Android App

Manage Android app installation source visibility by using USB transfers or file managers to reduce browser traces and isolate data via work profiles.

Read More
Connecting Momentus 4200.2 ST9808210A Hard Drive via USB Cable

Resolve inability to access Seagate Momentus 4200.2 ST9808210A hard drive by connecting it via USB using a compatible SATA-to-USB adapter and configuring the disk in Windows.

Read More