Creating new drafts from new text files in a folder on Mac

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?

1 Like

In Automator, you would need to be reading the content of the files, then you could create the drafts with appropriate tags using AppleScript. Docs have an example of creating a draft with tags via AppleScript.

I admit my Automator knowledge is a bit rusty, so I’m probably not much help beyond that.


Try this folder action Automator workflow.


  • Works on text based files.
  • Creates draft based on file content.
    • 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.


Hope that helps.


I am getting the attached output when I try to download the workflow:

Screenshot 2022-03-19 at 16.44.10

1 Like

Fixed it in the post above - I had a typo in the URL (‘draft’ should have been plural - ‘drafts’).

Dumb question, how do I run the Automator action?

You tie it to a folder then add a text file to the folder.

See the first paragraph of the original post or search the web for Automator folder actions.

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?

Solved the docx to txt issue with a shell script:

textutil -convert txt /Users/stu/Dropbox/Apps/Postbox/A/*.docx

But now I’m returning this error:

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.

1 Like

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.

Everything works til I get that error:

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.

1 Like

Thank you, that has worked a treat!

I didn’t know how to export a workflow, but figured that out now - here’s where I’d got to:

One last question - which bit of the script is adding the date to the name? Ideally I’d like the name to just be the file name, no date added.

But it’s working great as it is, very happy bunny. Thanks again.

I didn’t have anything that used the date at any point for anything, so it should not have come from what I shared.

I will have to look at what you have done with your workflow after I finish work for the day.

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 as a fullscreen window I Firefox on launch.

drafts in there are then saved to, 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.