Restoring exported Attachments' and Documents' filenames

posted Apr 5, 2011, 7:47 PM by Ezra Kenigsberg   [ updated Apr 5, 2011, 9:05 PM ]

#DataTipOfTheDay 2011-04-05

Q: "How do I restore the filenames of Attachments and Documents downloaded using Data Export?"

A: If you use Data Export to export Attachments and Documents, you've probably noticed that the exported files' names have been changed to their Salesforce IDs (an 18-character code that begins with "00P" for Attachments and "015" for Documents).

To restore the Attachments' original names, do the following:
  1. Open the file "Attachment.csv" in Excel
  2. Delete all columns but "ID" and "Name". Once all 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.
    ="RENAME "&A2&" """&B2&""""
    The resulting cell should look like this:
    RENAME 00P300000046RlaEAE "Technical Specifications V1_2.docx"
  4. Copy cell C2 and paste it all the way down column C, to the last row that has ID and Name values in it.
  5. Select column C and copy it.
  6. Open Notepad.
  7. Paste the copied cells into Notepad.
  8. Click File|Save in Notepad, and save the file in your exported Attachments directory as "Fix.bat" (without the quotation marks).
  9. Navigate to your exported Attachments directory and double-click "Fix.bat". It should rename all the Attachments appropriately.
  10. Close "Attachment.csv" in Excel without saving any changes.
The procedure for restoring the Documents' original names is similar:
  1. Open the file "Document.csv" in Excel
  2. Delete all columns but "ID", "Name", and "Type". Once all other columns are deleted, "ID" should be in column A, "Name" should be in column B, and "Type" should be in column C.
  3. Copy the formula on the following line and paste it into cell D2.
    ="RENAME "&A2&" """&B2&IF(RIGHT(B2,LEN(C2))=C2,"","."&C2)&""""
    The resulting cell should look like this:
    RENAME 01530000000cmjjAAA "Setup Checklist.png"
  4. Copy cell D2 and paste it all the way down column D, to the last row that has ID, Name, and Type values in it.
  5. Select column D and copy it.
  6. Open Notepad.
  7. Paste the copied cells into Notepad.
  8. Click File|Save in Notepad, and save the file into your exported Documents directory as "Fix.bat" (without the quotation marks).
  9. Navigate to your exported Documents directory and double-click "Fix.bat". It should rename all the Documents appropriately.
  10. Close "Document.csv" in Excel without saving any changes.
Comments