Print this page

Renaming exported Attachments files in a data export on MAC

Knowledge Article Number 000232859
Description When requesting a Full Data Export, you will notice that all attachments are placed in the Attachments subfolder and named with their Salesforce ID, not the actual file name or extension. One must then consult the Attachment.csv file included in the data export to find the name associated with the ID and rename the file. Salesforce ID for Attachments has an 18-character code that begins with "00P" and "015" for Documents each with their own .csv and folder.
Resolution The following steps can be taken on a MAC machine where the user should have Admin privileges to rename the records, these steps are for Attachments but, they should be easily modified for other types of records:
 
1. Open the file "Attachment.csv" in Excel 
2. Delete all columns but "ID" and "Name". Once all the other columns are deleted, "ID" should be in column A and "Name" should be in column B. 
3. Copy the formula on the following line and paste it into cell C2. 
="mv "&A2&" """&B2&""""
4.The resulting cell should look like this: 
mv 00P300000046RlaEAE "Technical Specifications V1_2.docx" 
5.Double-click the lower right corner of cell C2 to copy all the way down to column C.
6.Select column C and copy it. 
7.Open Notepad. 
8.Paste the copied cells into Notepad. 
9.Click File|Save in Notepad, and save the file in your exported Attachments Folder as "Rename.sh" (without the quotation marks).  This is where the records to be renamed are located.
10.Navigate to your exported Attachments directory and double-click "Rename.sh". It should rename all the Attachments appropriately. 
11.Close "Attachment.csv" in Excel without saving any changes.

In summary, these steps help you generate a text file that uses the unix system's mv command which can be used to either move or rename a file. If you move a file with a different name in the source directory itself instead of destination directory it will be renamed.


Steps to open Terminal in MAC:

Go to path :  System Preferences > Keyboard > Shortcuts > Services >> Terminal

Mac Terminal

Now, run Shell Script

Shell script can be run in two ways

1) change file permissions using command: chmod -x <rename.sh>
and type name of file against Terminal prompt and press enter.
OR
2) Type command "sh <rename.sh>" against Terminal prompt and press enter

mv command screenshot

Related References:
Renaming exported Attachments/Documents files in a data export
 




promote demote