6 Ways to Batch Rename Files on Mac
Renaming a bunch of files at once can be challenging. Luckily, MacBooks have built-in tools, like Automator and AppleScript, that allow you to easily rename multiple files in a batch. Alternatively, you can download third-party apps to batch-rename files on your Mac, and in this guide, we take a look at both options.
1. Using Finder
You can use Finder to batch rename files on Mac. Note that the method only adds prefixes/suffixes and not full file names. But you can still do a lot, like replacing words in batches or changing formats. Follow the steps below to change file names using Finder.
- Locate the files you want to rename inside Finder.
- Select all of the files you wish to rename.
- Click the three dots in the top right of the Finder window. Select “Rename” from the drop-down menu.
- Click the “Replace text” drop-down menu in the pop-up.
- Choose “Add Text” from the drop-down menu. Type the words or characters that you want to replace the file names, then select whether you want to insert them before or after the current name in the adjacent drop-down menu.
- Click “Rename” to change file names.
2. Using Automator
Automator is a built-in app in macOS that’s designed for automating repetitive tasks. The app allows you to assemble similar tasks into batches, such as batch rename files, but there are hundreds of other Mac options to choose from in the Automator Library. Follow the steps listed below to use the batch rename option.
- Launch Finder and select “Applications” in the left sidebar.
- Find and click “Automator.”
- Click on “New Document” in the bottom left of the new window.
- In the pop-up window, click on “Workflow,” then “Choose.”
- Select “Library” from the left sidebar in the new document.
- Click “Files & Folders” to access the list of all of the files inside the Automator Library.
- Find and double-click the “Get Specified Finder Items” folder. Alternatively, drag and drop the folder to the workflow pane.
- Double-click or drag and drop the “Rename Finder Items” folder to the workflow pane. If you drag the folder, drop it below the “Get Specified Finder Items” folder.
- If a dialog box appears warning about the changes made to the names of the Finder items, select the “Don’t Add” button.
- Click “Options” located above the “Get Specified Finder Items” box.
- Three options will appear under Options. Check the box next to “Show this action when the workflow runs.”
- Go to the “Rename Finder Items” option and select the drop-down menu that says “Add Date or Time.”
- Click “Make Sequential” in the menu.
- Find and check the “new name” option beside “Add number to existing item name.”
- Go to “Options” in the bottom left of the “Rename Finder Items” section.
- Check the box next to “Show this action when the workflow runs.”
- Click “Add” to add the batch of files you wish to rename.
- Select the batch of files and click “Add.”
- Add the name you want to use to rename the batch of files.
- You can adjust the naming settings to your preferences. You will see how the name will look in the “Example” field.
- The workflow is complete. Select the “Run” button in the top-right corner.
- A dialog box will open. Click on “Continue.”
- Another dialog box will appear showing the renaming settings. Click “Continue” to proceed.
- The workflow will start running, and all of the selected folders will be renamed.
3. Using AppleScript
AppleScript is another useful macOS built-in tool to batch rename files and folders. It is a scripting language that can help automate tasks using the preinstalled Script Editor on your Mac. Follow the steps below to use it:
- Navigate to “Applications -> Utilities folder” and launch “Script Editor.”
- Select “File” and click the “New Document” option to create a new script.
- Copy the following code and paste it into the Script Editor window:
--This code is from https://gist.github.com/oliveratgithub/
settext item delimiters to"."tell application "Finder"set all_files to every item of (choosefilewithprompt"Choose the Files you’d like to rename:"with multiple selections allowed) aslist
display dialog "New file name:"default answer ""set new_name totext returned ofresult
--now we start looping through all selected files. ’index’ is our counter that we initially set to 1 and then count up with every file.--the ’index’ number is of course required for the sequential renaming of our files!
repeatwithindexfrom1to the countof all_files
--using our index, we select the appropriate file from our listset this_file to item indexof all_files
set {itemName, itemExtension} to {name, name extension} of this_file
--if the index number is lower than 10, we will add a preceding "0"for a proper filename sorting later
ifindexislessthan10then
set index_prefix to"0"elseset index_prefix to""
endif
----lets check if the current file from our list (based on index-number) has even any file-extensionif itemExtension is""then-- ""means there is no file-extension present.set file_extension to""else--yup, we are currently processing a file that has a file-extension--we have to re-add the original file-extension after changing the name of the file!set file_extension to"."& itemExtension
endif
--let’s rename our file, add the sequential number from ’index’ and add the file-extension to itset the nameof this_file to new_name & index_prefix & index & file_extension asstring
endrepeat
--congratulations for successfully accomplishing the batch renaming task:)
display alert "All done! Renamed "& index & "files with ’"& new_name & "’ for you. Have a great day!:)"end tell
- Click on the Hammer icon to compile the script.
- Open “File” from the top toolbar, then click on the “Save” button to save the script.
- Click the Play button in the Script Editor window to run the script.
- A new window will appear, asking you to select the files you want to rename. Navigate to the folder containing these files, select them, and click the “Choose” button.
- Another dialog box will appear, asking you to enter the new name for the files. Enter the new name and click “OK.”
- The script will run and rename all of the files in the selected folder with the new name. The files will also be given a number suffix to ensure they are unique. You’ll receive a confirmation message when the renaming is complete.
- Close the Script Editor window.
- Check the folder to confirm that the files have been renamed.
If you want to modify the file extension, use the code below and compile it in the Script Editor the same way the code was compiled above.
settext item delimiters to"."tell application "Finder"set all_files to every item of (choosefilewithprompt"Choose the Files you’d like to rename:"with multiple selections allowed) aslist
display dialog "New file name:"default answer ""set new_name totext returned ofresult
display dialog "New file extension:"default answer ""set new_extension totext returned ofresult
--now we start looping through all selected files. ’index’ is our counter that we initially set to 1 and then count up with every file.--the ’index’ number is of course required for the sequential renaming of our files!
repeatwithindexfrom1to the countof all_files
--using our index, we select the appropriate file from our listset this_file to item indexof all_files
set {itemName, itemExtension} to {name, name extension} of this_file
--if the index number is lower than 10, we will add a preceding "0"for a proper filename sorting later
ifindexislessthan10then
set index_prefix to"0"elseset index_prefix to""
endif
----lets check if the current file from our list (based on index-number) has even any file-extensionif new_extension is""then-- ""means there is no file-extension present.set file_extension to""else--yup, we are currently processing a file that has a file-extension--we have to re-add the original file-extension after changing the name of the file!set file_extension to"."& new_extension
endif
--let’s rename our file, add the sequential number from ’index’ and add the file-extension to itset the nameof this_file to new_name & index_prefix & index & file_extension asstring
endrepeat
--congratulations for successfully accomplishing the batch renaming task:)
display alert "All done! Renamed "& index & "files with ’"& new_name & "’ and file extension ’"& new_extension & "’ for you. Have a great day!:)"end tell
When you run this script, you’ll get a new option to select the new file extension for the files you want to rename. Add your desired file type and click “OK.”
You’ll get a confirmation message stating that your files have been renamed and the file type has been changed to the one you specified. You can check your folder to verify that.
4. NameChanger
NameChanger is a free, simple, and easy-to-use file rename app. You can easily download the app and batch rename files and folders on your Mac. To do that, drag and drop the required files onto the app.
There are various options to change the file names, including:
- Replace First Occurrence
- Replace Last Occurrence
- Replace All Occurrences
- Wildcard
- Append
- Prepend
- Date
The best thing about NameChanger is that it instantly shows the changes made without renaming the files. After entering the data in the text fields, click the “Rename” button to change the files’ names.
How to Use NameChanger
To batch-rename files using NameChanger, first download the app and open it, then start renaming files as shown below:
- Choose the files you want to rename and drag and drop them to the left sidebar in the app. Alternatively, select the “Add” button to add files to the app.
- Click the drop-down menu to access different renaming features. Select the desired option.
- Depending on your selected option, a pop-up window will appear with multiple options. For instance, the “Sequence” option allows you to include the number of digits in the file name, location, and arrangement style for files.
- Click the “Rename” button to change the name of all added files.
5. Renamer 6
Renamer 6 is another third-party file-changing app that allows you to quickly rename files and folders. It offers multiple ways to change file names, which is a great feature if a chosen method doesn’t work for selected files or folders.
Here are some of the other unique features of this batch file renaming app:
- Organizes your renaming tasks into Renamerlets
- Ability to create various assembling chains for complex file-renaming tasks
- Shows a live preview of the new name
- Ability to undo and back up your files without worrying about losing data
6. Smart File Renamer
This third-party file renaming app is excellent for changing multiple media names. Beside files and folders, the Smart File Renamer supports audio, photos, file tags, and many more file types. With smart filters and custom rules, you can quickly rename your files without manually adding the data.
Remember, you can use the free version of the app, but it doesn’t offer unlimited renaming. You need to buy the premium version to access the unlimited renaming feature.
Frequently Asked Questions
Can I use Automator or AppleScript to rename files only in a specific folder?
Yes. Select the files within the desired folder to rename them in both Automator and AppleScript.
Can I undo a batch renaming process if I made a mistake?
Yes, as most third-party apps have an undo feature. If you’ve made a mistake in the new name, you can quickly undo it and rename the files again.
How can I add specific text or numbers to the beginning or end of a batch of file names?
You can add specific text or numbers to the beginning or end of a batch by entering the required characters in the particular text or number fields. Both built-in and third-party apps have fields specific to different text or numbers, which you can use to rename your files.
Can I rename files with different extensions in one batch renaming process?
Yes, you can rename files with different extensions in one batch. Since no additional step is required while renaming batch files with different extensions, each file will be renamed regardless of its extension.
Is there a limit to the number of files I can rename at once using Automator or AppleScript?
No, Automator and AppleScript don’t limit the number of files you can rename at once. However, you must ensure the workflow or code is written correctly.
Can I use a third-party app to rename files on my Windows computer as well?
Yes, you can use any third-party app to rename files on your Windows computer. Many third-party apps are available on the Web to batch rename files quickly. Some popular apps are File Renamer Basic, Bulk Rename Utility, and Advanced Renamer.
Is there any risk of data loss while renaming files in batch?
The name of the files and the data they contain are independent of each other. Renaming batch files should not risk data loss. However, you may lose data by renaming files if sensitive info is encoded into their names. Since renaming changes the file name, you may lose data embedded into the file name.
Image credit: Unsplash. All screenshots by Ojash Yadav.
- Tweet
Leave a Reply