Hi, trying to create a Folder Action in Automator on Mac so that when a new file is added to a specific folder that file is read and used to create a new draft with specific tag - ‘scratch’ - and put in the ‘flagged’ workspace.
Cannot find a way to connect them up, but I’m thinking that surely someone has already tackled this elsewhere? Can’t find anything on forums, and tried a few variants with shortcuts and Automator but no joy.
Best I could manage was a shortcut posting the file path into a new draft. Close, but pas de cigar. Can’t just be me who wants to route text files from other places into Drafts for processing?
Also prefixes base file name as a level 1 Markdown heading.
Marks the draft as flagged.
Tags the draft with “scratch”.
Generates a notification for when processing is complete.
Hopefully, this is close to, or just what you want, and you can take out any additional stuff you do not want, and tailor the workflow further to suit any additional needs.
Extra Information
Note, flagged is not a workspace in Drafts, it is an attribute of a draft.
Hi, thanks so much for this. I’m seeing this error when I run this script:
Finder got an error: Can’t make {} into type integer.”
Any idea?
Also, the programme I’m auto-saving files from saves them as .docx by default. Thinking this is part of the problem? Is there a way to convert them to .txt files before running the drafts script?
The action “Run AppleScript” encountered an error: “Finder got an error: Can’t make {alias “Macintosh HD:Users:stu:Dropbox:Apps:Postbox:A:2022-Mar-19 How long is Spring.txt”, alias “Macintosh HD:Users:stu:Dropbox:Apps:Postbox:A:2022-Mar-19 ff.txt”} into type integer.”
What am I doing wrong? Thanks for your help on this.
A docx file would definitely be hard to deal with for a text only import. Your option to convert using textutil is exactly what I would have suggested pre-processing with.
I’m not at home at the moment, so I’m not at my Mac to check this, but I know the automation worked for me when I created it. I will take a look later to see if I can figure out how to reproduce the issue you are seeing.
In the meantime, have you made any changes to the automation, such as integrating the textutil processing? If so, please share your revisions.
I’m not familiar with AppleScript or sophisticated enough to add the textutil, so I added that as a Run Shell Script at the beginning and then added steps to filter the finder items to text files created today.
My assumption, based on the above, is that you are potentially being quite generic in how you are processing docx files and passing a Posix rather than HFS path to the AppleScript, hence when it tries to alias it fails.
In my testing, this revised Automator workflow will pick up a DOCX file, convert it to TXT, delete the DOCX, import the TXT content into Drafts (functions as previous workflow), and then delete the TXT file. Rather than processing text files, this one is set to process files with the docx file extension.
FWIW, much like I have been doing for you, the best way to share what you have is to share the actual workflow file rather than just a description. It often does not give the whole picture, and means the recipient is then building elements by hand and interpretation instead of getting an instant, exact copy of what the other has.
Sorry you’re right, the file name is dated. I’m an idiot.
The full context of my workflow is that I wanted to turn an old Thinkpad into a typewriter, then have whatever I type appear in Drafts where I do my editing before pushing final pieces to IA Writer for final formatting.
For the Thinkpad I tried a bunch of distros but eventually installed ubuntu as it ran smoothest, and then included a script which launches sprinter.getfreewrite.com as a fullscreen window I Firefox on launch.
drafts in there are then saved to postbox.getfreewrite.com, which saves a file automatically to a linked Dropbox folder.
This automator workflow is then running off the associated Dropbox folder.
Been a labour of love, but very happy with the outcome. Been figuring this out for months, so thanks again. Will leave you in peace now.