How Do I Import Multiple Files into Adobe InDesign?

I’m a keyboard maestro novice. Is it possible to create the following macro without coding?

  • Open an “import file” dialog box within an application (this is a simple keystroke command).
  • Once the dialog opens to a folder, an X number of files will reside in that folder and I need to grab that number. So I need for either keyboard maestro to get this number of files and store it as a variable or it can pause and I can enter the number manually and click continue.
  • Next, keyboard maestro repeats a keystroke the number of times specified in the variable, subtracts one from the variable, and executes the return keystroke to close the dialog box, thereby importing the file.
  • Now I need keyboard maestro to cycle back to the first step (open dialing box) and repeat the steps—each time subtracting one from the stored variable. Thus, the keystroke repeat will be less one from the previous time.
  • The updated variable will not only determine the number of keystroke repeats but also determine when the macro ends (when the variable reaches zero).

Or maybe there’s a simpler way to do this?

As you’ve probably guessed, I’m trying to import all the files within a given folder, in the order they appear, and end the macro with the last file.

Any help or advice would be appreciated.

In which program are you importing the files?
And which types of files is it?

That … and do you know the folder in advance (I assume “yes”). I.e., could your macro interact with that folder and cause that app to import without using the import dialog?

I’m not sure Keyboard Maestro can easily interact with a modal dialog (such as the Import dialog) within an application.

I am importing into Adobe InDesign.

The files will come from various clients and will usually be MS Word or other WP files (usually saved as “.docx” or “.doc”).

Without getting into the weeds too much, it would not be desirable to combine files in another app and then import one file. The issues are how InDesign handles automatically numbered footnotes and endnotes—which often cause numbering problems when imported.

Ok, as long as I’m in the weeds, InDesign allows users to run “.jsx” scripts and there are 2 scripts out there that should theoretically solve my batch import problem but I’ve tested them and they don’t work as advertised for me. Similarly, within InDesign, one can “select all” and import all the files at once but that is not desirable for other reasons. So the files will need to be imported one at a time and in order.

I know the folder name and location in advance. I would probably use the same folder for this macro to make things simple. I’d call it something like “Import these” but if need be, I can make changes to the macro before running it (folder path location, number of files, etc). That would be OK.

Perhaps I am naive, but even with my limited knowledge, I see no reason why keyboard maestro will not properly interact with the import dialog box. I have already tested the simple steps. For example:

  1. open import dialog
  2. press up arrow key 5 times
  3. press return key

That would import the first file from a folder that contained 5 files. If the variable was then changed to 4, the macro could repeat (I assume) and import the second file, etc.

What has me stumped is the variable, subtracting one from it, and having 2 of the processes take their repeat values from that one variable. I need to be able to process 20+ files at a time to make it really useful. In a project with 300 such small files, I could process 30 files at a time (run the macro 10 times) and get the job done.

Make sense?

Thank you both for your interest.

I am a InDesign user as well.

Are the cursor placed in a text-frame?

Need to know if you have to click the mouse and place the text before importing the next file.

Hi Jimmy,

Yes, the cursor is in the text frame. Importing a file will automatically flow text and add pages without need of any mouse clicks.

I think the macro below will do the trick.

You need to change the actions in green.
The first set the folder location of your Word-files.
And the other green action sets the version of InDesign.

The macro works like this.
It makes a list of files in the directory with files to import. REMEMBER to make sure it is only Word or textfiles.
It then loops over this list and drives the GUI in InDesign with keystrokes.

The pauses are paced after my system and the test-files. Maybe you also need to adjust those to your needs.

Here is a short video showing it in action:

Keyboard Maestro “Import text into InDesign” Macro

Import text into InDesign.kmmacros (8.3 KB)

1 Like

Jimmy, amazing job! Thank you!

I tried the macro without changing the folder name/path (so as not to introduce errors). I created a folder on my desktop with the same name as in your macro.

I modified the macro to reflect my version of InDesign.

When the dialing box came up the path text was blank and there were no options in the scroll down list. Any ideas as to what I did wrong?

You have to trigger the macro when you are in InDesign and the cursor is in the textframe.
And maybe tweak the pauses.

I watched the macro run a few times. The script seems to be failing for me right at the point when the path to each file that needs to be processed is to be inserted in the dialog box. This is the step, I believe.

Nothing is retrieved/entered into the text field so it looks like this (regardless of any pauses added).

Since this field remains blank, I just hear a series of beeps as the macro fails through all the steps.

Here is a telling clue, however! The number of beeps seem about right in terms of how many cycles the macro should go through if it worked. In other words, if there are 2 files in the target folder, there are less beeps than if there are five files.

Make sense?

Which version of macOS are you running?

Or maybe try to insert a tab keystroke before, so the cursor is in the textfile.


If you re referring to the “go to folder” dialog box text field, the cursor is blinking in there, so that’s not the problem. But for some reason, the variable (path to file) is not getting inserted. I feel as though I’m on the verge of this working but I just don’t know enough about what is going on with that path/filename to fix it.

I am running Mac OS: 10.12.3 (16D32)

Thanks again for your endeavors.

@macpublish, I hope you don’t mind that I renamed your topic:

  • From: Repeating macro the number of times in a variable and subtracting one from variable
  • To: How Do I Import Multiple Files into Adobe InDesign?

in order to better reflect the contents, and to aid others in finding your topic.

cc: @korm, @JimmyHartington

No, I don’t mind you renaming the topic.

I had a chance to do some more tests and I believe the problem lies not in the macro but in the fact I’m running an old version of InDesign with the latest Mac OS. Updating to the latest version carries a steep monthly fee so I will just import the files manually for now. Thanks for the macro. Maybe it will help someone else looking to solve a similar problem.

OK. Then change the Insert Text by pasting to Insert text by typing.
You just need to click the dropdown in the action to change it.

1 Like


I thought of that and already tried it. It worked, sort of. However, I cannot get the macro to work reliably. It fails at different steps and different times (even with longer pauses added, etc). A couple of times it did cycle through a 5 file test, so we know that the macro works. I believe that the problem is my older version of InDesign being somehow incompatible with the latest Mac OS.

On the plus side, I came up with a very workable hack using a script I found online and I learned a few things about keyboard maestro thanks to your macro.

Many thanks.

I am happy to report that the macro worked for me after some more adjustments. I will give a brief summary in case anyone else has the same situation as me.

After a lot of testing I determined that there were several problems but the major hangup was that I was using the latest Mac OS with an older version of InDesign. For anyone who remembers numbering files like this (to get them in order in a folder), this will be familiar:
01-some name.docx
02-some name.docx

Somewhere along the way this was rectified so now the Mac OS understands the correct order for:
1-some name.docx
2-some name.docx
10-some name.docx
11-some name.docx

In the past, 10 and 11 would have followed 1. 2 would have followed 11

So the problem was that even though the files appeared to sequence correctly in InDesign’s place dialog box, they imported in the old order (1, 10, 11, 2). So I made a macro that first cycles through all the files in a folder and adds a time stamp to the front of each file name. So now the files look something like this:
1-some name.docx becomes “135233-1-some name.docx"
2-some name.docx” becomes "135234-2-some name.docx"

In addition to this, I had to change the “insert text by pasting” to “insert text by typing” (as you already figured out) and add full one second pauses in places. Also, I had to add a couple of returns in case dialog boxes (such as “missing font”) came up during the place procedure. For good measure, I added some unique text before each new file “%%%NEW FILE STARTS HERE%%%” which will make it easier to find any problems.

I ran some tests last night on a folder with 40 actual job files that would have normally failed due to various conditions (sequencing, missing fonts, etc) and it worked!

Well, this is pretty long just on the off chance that someone else might be in the same situation but who knows? Sorry about the verbosity.

Thanks again for the great macro! I hope to utilize it quite a lot in the future. In addition, I have the script hack as a back up but this is a much slicker solution.

1 Like

Glad to hear it worked.