منوعات تقنية

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.

Good to know: looking for the best Finder settings? We can help you out.

  1. Locate the files you want to rename inside Finder.
  1. Select all of the files you wish to rename.
Select All The Files You Wish To Rename
  1. Click the three dots in the top right of the Finder window. Select “Rename” from the drop-down menu.
Click Three Dots In The Top Right And Select Rename From The Drop Down Menu
  1. Click the “Replace text” drop-down menu in the pop-up.
Click The Replace Text Drop Down Menu
  1. 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.
Choose Add Text Type The Words To Replace The File Names And Select Before Or After Name
  1. Click “Rename” to change file names.
Select Rename To Change File Names 1

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.

  1. Launch Finder and select “Applications” in the left sidebar.
Launch Finder And Select Applications In The Left Sidebar
  1. Find and click “Automator.”
Find And Click Automator
  1. Click on “New Document” in the bottom left of the new window.
Select New Document At The Bottom Left Of The New Window
  1. In the pop-up window, click on “Workflow,” then “Choose.”
Click Workflow And Select Choose In The Pop Up Window
  1. Select “Library” from the left sidebar in the new document.
Select Library From The Left Sidebar In The New Document
  1. Click “Files & Folders” to access the list of all of the files inside the Automator Library.
Click Files And Folders To Access All The Files Inside The Automator Library
  1. Find and double-click the “Get Specified Finder Items” folder. Alternatively, drag and drop the folder to the workflow pane.
Drag And Drop Your Files
  1. 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.
  1. If a dialog box appears warning about the changes made to the names of the Finder items, select the “Don’t Add” button.
Click Do Not Add
  1. Click “Options” located above the “Get Specified Finder Items” box.
Click Options Located Below The Get Specified Finder Items Box
  1. Three options will appear under Options. Check the box next to “Show this action when the workflow runs.”
Check The Box Next To Show This Action When The Workflow Runs
  1. Go to the “Rename Finder Items” option and select the drop-down menu that says “Add Date or Time.”
Click Add Date Or Time
  1. Click “Make Sequential” in the menu.
Check The Box Next To Show This Action When The Workflow Runs Under Options
  1. Find and check the “new name” option beside “Add number to existing item name.”
Add New Name
  1. Go to “Options” in the bottom left of the “Rename Finder Items” section.
Go To Options Under The Rename Finder Items Section
  1. Check the box next to “Show this action when the workflow runs.”
Click Show This Action When Workflow Runs
  1. Click “Add” to add the batch of files you wish to rename.
Click Add To Add The File Batch You Wish To Rename
  1. Select the batch of files and click “Add.”
Select The File Batch And Click Add
  1. Add the name you want to use to rename the batch of files.
Write The Name You Want To Use For Renaming Batch Files
  1. You can adjust the naming settings to your preferences. You will see how the name will look in the “Example” field.
Adjust The Rename Settings By Changing The Place Number And Separated By
  1. The workflow is complete. Select the “Run” button in the top-right corner.
Select The Run Button At The Top Right Corner
  1. A dialog box will open. Click on “Continue.”
Click Continue In The Dialog Box That Opens
  1. Another dialog box will appear showing the renaming settings. Click “Continue” to proceed.
Click Continue To Proceed On The Rename Finder Items Dialog Box
  1. The workflow will start running, and all of the selected folders will be renamed.
Renamed Files

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:

  1. Navigate to “Applications -> Utilities folder” and launch “Script Editor.”
Navigate To Applications Click The Utilities Folder And Launch The Scripteditor
  1. Select “File” and click the “New Document” option to create a new script.
Click File And Select New To Create A New Script
  1. 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 list
set 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"
else
set index_prefix to""
endif
--
--lets check if the current file from our list (based on index-number) has even any file-extension
if 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 it
set 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
  1. Click on the Hammer icon to compile the script.
Click The Hammer Icon To Compile The Script
  1. Open “File” from the top toolbar, then click on the “Save” button to save the script.
Click File And Select Save To Save The Script
  1. Click the Play button in the Script Editor window to run the script.
Click The Play Button In The Scripteditor Window To Run The Script
  1. 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.
Navigate To The Folder Containing Files Select Them And Click Choose
  1. Another dialog box will appear, asking you to enter the new name for the files. Enter the new name and click “OK.”
Enter The New Name And Click Ok
  1. 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.
Batch Files Renaming Confirmation Message
  1. Close the Script Editor window.
  2. Check the folder to confirm that the files have been renamed.
Renamed Batch Files In A Folder

Note: the script will rename all of the files in the selected folder but will not change the file extension, even if you specify a file extension in the pop-up window.

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 list
set 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"
else
set index_prefix to""
endif
--
--lets check if the current file from our list (based on index-number) has even any file-extension
if 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 it
set 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.”

Set 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.

Batch Files Renamed With Specified File Type Confirmation Message

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.

Namechanger Mrr Software Batch File Renamer For Mac

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:

  1. 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.
Select The Add Button To Add Files To The App
  1. Click the drop-down menu to access different renaming features. Select the desired option.
Click The Dropdown Menu Of Replace First Occurrence With
  1. 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.
Edit The Renaming Details In The Pop Up Window
  1. Click the “Rename” button to change the name of all added files.
Click The Rename Button To Change The Name Of All The 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.

Renamer Batch File Renamer For Mac

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

Smart File Renamer For Mac

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?

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.

Ojash Yadav
Ojash Yadav

Ojash has been writing about tech back since Symbian-based Nokia was the closest thing to a smartphone. He spends most of his time writing, researching, or ranting about bitcoin.

Subscribe to our newsletter!

Our latest tutorials delivered straight to your inbox

اترك تعليقاً

لن يتم نشر عنوان بريدك الإلكتروني. الحقول الإلزامية مشار إليها بـ *

زر الذهاب إلى الأعلى