Syncing to Dropbox

Hi there

I have read Using Dropbox with Drafts but I am not sure how to sync a draft to Dropbox.

I mean I want to read the draft from a path on Dropbox and then after editing I want to write it back to the same path.

What’s the easiest way to do this?

Thanks for any pointers!

Post v4, Drafts uses iCloud for sync and so can’t auto-sync to files in Dropbox.

You can create actions that would let you read in a file from Dropbox and save back to it. This would be manually triggered. That refers back to the details in the post you linked to above.

I wrote a couple of actions to semi-automate the process of moving drafts to and from Dropbox:

It’s flexible in that it lets you save the draft anywhere in Dropbox, but it’s limiting in that you have to include the path to the file somewhere in the draft.

1 Like

If you always keep a single draft per file, you could consider moving the path out into an index (e.g. as a JSON file) where you could match a draft UUID and a file path. If it isn’t a persistent 1-2-1 match, you would probably also need to include an initial existence in index & drafts/ Dropbox check, and overwrite the index value if necessary.

More complicated to maintain, but does keep your files clean, which can be an issue if they are config files, or if there’s a variation in the formats, gets around the approach that’s commonly used of putting the path on the first line which then makes it the title, etc.

Thanks Dr. Drang! These scripts look great! I am checking it out!

Hi sylumer, interesting idea - not necessarily what I need, but I can see the point.

Thank you, sylumer, for the possibility of not needing to have the Dropbox path in the file.
I have dozens of text files on Dropbox that I would like to be able to sync with Dropbox in the manner you’re describing. Can you give an outline of what’s involved or point to a set of scripts or actions?
Blessings, and thank you!,
Richard Fairbanks

For a scripting action, UUID is a property of the Drafts object. The FileManager object now has JSON read and write functions.

Along with the Dropbox path, that gives you the Draft identifier and a way to save and retrieve key value pairs - match UUID and file path.

That’s the basic premise.

I’ve just started with Drafts, so if this has been answered elsewhere - sorry !

The “Save to Dropbox” action script is OK, but I’d like to get the Workspace and the tags as well as the content. Is that possible?

Then (there’s always more, isn’t there?) I’d like to be able to select all the notes, preferably sequentially and back them up to a DropBox folder I’ve created. I’d run that via an IOS shortcut, and then overnight the server would combine the notes into a single JSON blob. The server side is trivial, I just need to get the right data into DropBox first.

Is anyone able to point me at some documentation to help?

  • Run Action with text; you could query for all the Drafts that you want based on the above, and you don’t have to do anything with the text.

You could also just do that by appending to a file when writing from Drafts couldn’t you? What’s the server-side processing benefit here?

Hope that helps.

Thanks very much. That’s a great help.

The server-side process is as much me being comfortable with that approach as anything else. I’d get a JSON blob with individual notes any of which could be extracted if required. I’ll use the calls that you’ve mentioned though. Getting used to a sophisticated product takes time, and part of it is using the abilities that it provides without circumventing them.