jackddumpster. I’ve quoted from your post below, followed by my response.
In a different scenario, can you use a similar text input like your pdfFileName coming from AppleScript, eg. “/Users/user1/Desktop/original.pdf” (or any POSIX file string) and have the shortcut get somehow access to the actual pdf file whose name we received as input argument, and do something with it like splitting it and saving the individual pages (as your previous shortcut does, but in the same folder as the original.pdf in your demoed case above) ?
As regards a POSIX file string, the answer is no. However, you can pass the shortcut an alias or file object of a PDF, which will allow you to manipulate the PDF in whatever fashion the Shortcut app allows (e.g. splitting and saving each PDF page). There is a Get Parent Directory action, which would allow you to save the individual PDF pages in the same folder as the original.
For example, imagine the JSON text input your AppleScript passes as input to your shortcut, contains this string { “inputPDF” : “/Users/user1/Desktop/orginal.pdf”, “outputFolder” : “/Users/user1/DOWNLOADS/splitFilesFolder” }. You want to split whatever file is mentioned as the value of the “inputPDF” key… how do you do that?
As noted above, you cannot do this because you cannot create a file object in a shortcut from a POSIX path. However, you can pass the shortcut an alias or file object for inputPDF and an alias or file object for outputFolder. These alias or file objects can be passed to the shortcut as a list or record. I don’t believe a JSON can be used.
b) Can you ask Shortcuts to get a hold of any output folder in the filesystem (and prompt the user of course for permissions the first time around, yes) or does the output folders in Shortcuts get limited to anything that is in the same folder or parent folder as an input file, (if the shortcut was receiving as input directly PDF files instead of text)? For example, imagine the JSON text input your AppleScript passes as input to your shortcut, contains { “inputPDF” : “/Users/user1/Desktop/orginal.pdf”, “outputFolder” : “/Users/user1/DOWNLOADS/splitFilesFolder” }. Can you have the shortcut spit out the pages into that ~/Downloads/splitFilesFolder/ instead of the ~/Desktop/ which contained the original pdf…
The answer to this is pretty much the same as above–just pass the shortcut the alias or file object for inputPDF and the alias or file object for outputFolder. Another option is to prompt the user in the shortcut for the output folder, but I assume you don’t want to do this. A third option is to set outputFolder in the shortcut using a File action, but this cannot be changed by an AppleScript.
…and if yes, would you have to navigate by getting the parent of the original, then the parent of that (to get to the home directory ~user1/) and then how would you navigate down the directory tree to get to ~/Downloads/splitFilesFolder/ and put the pdf pages there?
I’ve never done this but it should work. However, it’s much easier just to pass the shortcut the alias or file object of the output folder.
The following is a simple example which illustrates the above:
set theFile to (choose file) -- an alias
set theFolder to (choose folder) -- an alias
tell application "Shortcuts Events" to run shortcut named "Split PDF" with input {theFile, theFolder}
Split PDF.shortcut (22.1 KB)
BTW, is there some reason you want to pass the shortcut a JSON instead of a list or a record?