Batch processing files

I am new to KBM. What I'm looking for is a way to automate a specific process. I use the mind mapping software called iThoughts. in iThoughts you can export a map to a PDF. I'm also teaching a course with 25 students where they submit mind maps on a regular basis.

Are there ways in KM to batch open a group of mind maps in a specific folder, then convert each of them to a PDF? This kind of batch processing would be good for other things as well.

I just don't know if this is even possible.

[I have adjusted your topic title to better represent your question]

You can use the For Each action with the Folder Contents collection to scan through a specific folder. Or you can work the the selected files in the Finder, see:

Either way that will let you iterate through the files. You then have to figure out the "open, convert to PDF, close" sequence, which will vary depending on the application. I'd consider something like:

  • Ensure there are no other files open
  • Open the file in iThoughts
  • Pause Until the Front Window title is appropriate.
  • Export to PDF - this will vary from application to application. It might involve printing to a PDF which is discussed elsewhere on the forum.
  • Close - Command-W or Select menu File ➤ Close.

The problem with iThoughts will be how to bring up the share sheet and navigate to PDF tab therein. I’ve done similar for images and also, I think, CSV.

(I want the CSV to feed into my filterCSV code. As an iThoughts user you might want this code anyway but it doesn’t create PDF.)

The way my “Export to” automation works is by UI manipulation (and UI Browser helped me get this right.) I can share a sample if you like.

Another possibility is to use File->Print (Cmd+P). That brings up Preview with the PDF in. Then you have to automate Preview.

iThoughts is a superb app and although it has no script support it reacts nicely to KM.

Here is an image of the basic steps that should export the frontmost file (so will have to add the loop that Peter Lewis mentioned). It basically shows how you can use KM's Button-Pressing capabilities to achieve this. It also demonstrates that there are some UI-Elements that can be considered buttons - even if they don't look like it (the "PDF-button" is a sort of mix between button and tab sheet – but it works at this particular place).
It is also very basic as it does not set a path or a name for the exported map (The macro will invoke a standard Save-sheet where you can easily paste a name in the selected field; a path is easy to add after adding a keyboard shortcut for Shift+CMD+G). Hope that get's you started.

Roland

ithoughts

2 Likes

Ah. I hadn’t spotted that. :frowning: :slight_smile:

Meaning “I hadn’t realised the text on the buttons was their name”.

@peternlewis @medienmeister @MartinPacker Thanks to all of you. This is very encouraging to know what I want to do is likely possible. Since I'm new to KM I may come back with some specific questions/confusions. But you've all provided a lot of grist for the mill. I'm looking forward to putting this macro together. But without your collective guidance there is zero chance I would have been successful on my own.

1 Like

If you are new to Keyboard Maestro, I always recommend you start simple and get an understanding of the basics of Keyboard Maestro before trying to string together a more complex macro.

Also remember with any complex task, if you can automate a chunk of the problem then that will help you in the mean time while you consider how to extend the macro to do more.

1 Like

@peternlewis Thanks, that's great advice!