I'm trying to import a folder full of pictures (bar codes), one per page in alphabetical order into InDesign.

I've found the following link which shows how to create a script that will turn the images into a CSV file which I can then data merge into InDesign.


The problem I'm having is that the script creates a CSV file but the images aren't listed in alphabetical order. I'm assuming there might be a default where they are imported by file size. If I reorder the images alphabetically in the CSV file the data merge changes from 'images' to 'text'. I would normally just import the images one by one but on this occasion, I have 5,000 (numbered SPA200001 to SPA205001).

Thanks in advance for any advice.

1 Answer 1


You probably don't need a script for this.

Just running this command in your particular folder using the command prompt ('cmd') in Windows will generate that list for you, alphabetically.

dir /on /b >> list.csv

It will just be a plain text file in this format:

image 1

image 2

image 3


image 5000

Then, add this at the top of that text file:


Then, setup and import using Data Merge as seen in most tutorials.

  • Thanks but I'm on a Mac platform.
    – jepplett44
    Commented Mar 17, 2020 at 0:29
  • Then, you can probably buy an app that can do this for you :)) Kidding. See this and try until it works osxdaily.com/2013/01/29/…
    – lmlmlm
    Commented Mar 17, 2020 at 7:31
  • Great info on the dos command. Only drawback was that the list.csv name was included in the list.
    – nocturns2
    Commented Mar 17, 2020 at 22:13
  • Yes, that does happen, but easy to remove in a text editor. With Data Merge there is always some degree of manually adjusting the data before merging.
    – lmlmlm
    Commented Mar 17, 2020 at 22:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.