Appending to file looks successful but isn't

I have a very simple action that appends the text of a draft to a file whose name is based on the date.

When I run the action, everything acts like it is working, the log entry show success…but nothing is being appended.

Here are the script and log results:

CleanShot 2021-06-27 at 09.53.01@2x

You are attempting to access a path outside of the Drafts iCloud folder in the Drafts iCloud folder.

See the description of the file action step.

If you are only wanting to do this on the Mac, you may want to have a read through this thread for an alternate approach.

Hope that helps.

Wow, that is quite a steep limitation. I already have some Keyboard Maestro and Alfred scripts that have no problem accessing those files directly, so I’ll probably just stop using Drafts. This was probably the only thing I’d have been using Drafts for, so easier to just skip it for now.

But thanks very much for the info!

It is because Drafts is a cross platform app and so has to comply with the sandboxing limitation for iOS and iPadOS. Keyboard Maestro and Alfred are single platform apps, their remote apps aside, they don’t have to conform to the same cross platform compatibility constraints.

That cross-platform compliance weakness is obviously based on the huge benefit of being equivalent across platforms. Additionally, it is possible to work around in a relatively straightforward and reusable way as I have demonstrated. As such I would not describe the situation as being a steep limitation.

I use Keyboard Maestro, Alfred and Drafts on the Mac. In fact I created the popular “Doctor Drafts” workflow for Drafts and Alfred.

If this was all you have been using Drafts for, then you are probably missing out on large swathes of functionality and use cases. I would recommend you look a bit deeper before discarding Drafts.

I used to use Drafts extensively, but it has become less and less needed/useful for my particular needs. I appreciate that what is for me a limitation is an artifact of being cross-platform (I use Drafts on my phone/tablet much less than I used to because I use those devices that way much less than I used to) and that “steep” is relative. I ended up solving the problem using a hacky Applescript step (I don’t know much Javascript :slight_smile: that has the added benefit of it not mattering if the file being appended to exists or not.

It’s all good. I’ve been a Drafts Pro user for many, many years and will continue to subscribe just to support the product. And I recommend it all the time. But right now I don’t need it as much!

BTW, I like Doctor Drafts, have been using it, and bought you a few coffees.

Also, here’s the Applescript step I hacked together:

on execute(draft)
	set thePath to "/Users/chris/Library/Mobile Documents/iCloud~md~obsidian/Documents/bujo/journals/"
	set theExt to ".md"
	set theText to return & "- " & content of the draft & return
	set theDate to (current date)
	set dday to day of theDate as text
	if length of dday is less than 2 then
		set dday to "0" & dday as text
	end if
	set theMnth to month of theDate as integer
	if theMnth is less than 10 then
		set theMnth to "0" & theMnth as text
	end if
	set theYr to year of theDate as text
	set myDate to theYr & "_" & theMnth & "_" & dday as text
	set myFile to thePath & myDate & ".md" as text
	tell application "Finder" to set selectedFile to POSIX path of myFile
	do shell script "echo " & quoted form of theText & " >> " & quoted form of selectedFile
end execute
1 Like

I get around all of this by using Dropbox. I’m sure other cloud services would work as long as there’s an API with an append-to-file endpoint/action.

That’s normally what I would do, but I am using the Obsidian mobile app to access my loggseq files (since logseq doesn’t yet have a mobile app) and that requires iCloud for now!