How Can I Create a Sub-Folder for Each PDF in The Parent Folder, and Move and Process the PDF?

I look forward to a new learning curve and hopefully there is enough brain cells left to do the job !

My goal is to create a script that will scan a folder for any "PDF" files and when it finds a PDF, it will

  • Create a folder within the folder with the same name as the PDF.

  • Move the PDF into the folder

  • Open the PDF in "Preview

  • Create a Screen Shot by using "Shift,Command, 5

  • So end result is a folder with the PDF and a ScreenShot of the PDF

  • Rinse and repeat until all the PDF's are processed.

Is this doable?
Please advise
Ron from Canada

Hi @rphillipchuk, welcome to the Forum. This sounds like a perfect job for the App Hazel to handle. I love Keyboard Maestro and use it for so many things but every now and then it is simpler to just use a dedicated small App.

But I know (from my own experience) that it is quite annoying to reach out to a Forum and be told "you shouldn't be doing that"... I had it recently on a Final Cut Pro Forum where I was seeking an obscure keyboard shortcut and was told "how lazy can you be that you can't just click the mouse?..." :smiling_face:

Having said that, yes, I think it would be possible to build a series of Actions in Keyboard Maestro to do this - it's just that scanning Folders for changes is very much a Hazel thing and you could get this going a lot faster by going down that route I think.

I resisted installing Hazel for years (like most on this Forum I wanted to limit the amount of third party Apps I rely on). And of course there are cross-over cases where two different Apps can do the same thing. But Folder Actions is Hazel's whole reason for existence.

So would that be an image of just page 2 of the file, as you have shown, or what? Please explain more fully.

I open the PDF with "Preview" and capture a screenshot with "shift ,command, 5"

Yes I know that - you said so in your first post. What I’m asking is this: do you want the screenshot to always be of page 2 of the PDF, as you have shown? If not, what determines which page is to appear in the screenshot (is it sometimes page 1, or page 3, or... and why)?

I really like the embellished preview which is the first page....The thumb nails on the left makes all the difference to me.

I do not have the expertise to give you the proper technical name, all I know is that when I open up a PDF in preview, it gives me the image that I am looking for. Then all I do is Shift, Command, 5 to capture the screenshot.

As @Zabobon has rightly suggested, this could be achieved using the Hazel app in conjunction with, say, Automator.

However, if you already own KM but not Hazel then you can certainly achieve your goal using KM in conjunction with an Automator workflow (to turn the pdfs into images).

It may be someone else here has already done something similar who can help out!

To get you started though here's a KM template macro that steps through the current Finder selection. You can adapt it as you like.

Step through Finder Selection.kmmacros (9.3 KB)

KM 0 2021-02-12_17-00-18

I hope you don't mind that I have revised your topic title to better reflect the question you have asked.

The start of a new Journey

How Can I Create a Sub-Folder for Each PDF in The Parent Folder, and Move and Process the PDF?

This will greatly help you attract more experienced users to help solve your problem, and will help future readers find your question, and the solution.

No offence taken....... Thanks