When Salesforce users perform a Data Export, the downloaded ZIP file contains a Documents folder. The files in this folder are named using their Salesforce Record IDs (for example, 015300000046RlaEAE) instead of their original document names.
This article explains how Mac users can use the Terminal application and a shell script (.sh file) to batch rename exported files back to their original names using information from the Documents.csv file included in the export.
Note: For Windows instructions, refer to the article Rename exported attachments or document files.
Open Documents.csv in Microsoft Excel.
Delete all columns except ID and Name.
The ID column should be in column A.
The Name column should be in column B.
In cell C2, enter the following formula:
="mv "&A2&" """&B2&""""
Understanding the Formula
The formula creates a Mac Terminal rename command for each file. For example, if a file has the Salesforce ID 015300000046RlaEAE and the original filename Technical Specifications V1_2.docx, the formula generates:
mv 015300000046RlaEAE "Technical Specifications V1_2.docx"
This Terminal command renames the exported file from its Salesforce ID to its original document name.
Double-click the lower-right corner of cell C2 to copy the formula down for all rows.
Copy all values from column C.
Open TextEdit on your Mac and paste the copied content.
Convert the file to plain text by pressing Command + Shift + T.
Save the file as rename.sh in the exported Documents folder.
Open Terminal.
You can launch Terminal using Spotlight Search by clicking the magnifying glass icon and searching for Terminal.
Navigate to the exported Documents folder by typing:
cd
followed by a space, then drag the Documents folder into the Terminal window and press Enter.
Grant execution permissions to the script:
sudo chmod 777 rename.sh
Enter your Mac password when prompted.
Run the script:
sudo ./rename.sh
The script will process each command and rename the files in the Documents folder to their original names.
After confirming the files have been renamed successfully, close Documents.csv without saving any changes.
VIDEO: Salesforce Support video demonstrating how to rename exported document files on a Mac using Excel, TextEdit, and Terminal. The video covers opening Documents.csv, generating rename commands, creating the shell script, running the script in Terminal, and verifying that the files have been renamed successfully.
000381782

We use three kinds of cookies on our websites: required, functional, and advertising. You can choose whether functional and advertising cookies apply. Click on the different cookie categories to find out more about each category and to change the default settings.
Privacy Statement
Required cookies are necessary for basic website functionality. Some examples include: session cookies needed to transmit the website, authentication cookies, and security cookies.
Functional cookies enhance functions, performance, and services on the website. Some examples include: cookies used to analyze site traffic, cookies used for market research, and cookies used to display advertising that is not directed to a particular individual.
Advertising cookies track activity across websites in order to understand a viewer’s interests, and direct them specific marketing. Some examples include: cookies used for remarketing, or interest-based advertising.