Files saves inside database, how big a problem is this?

This is for @BLUEFROG and the DT boffins.

I’m doing some script writing using Atom as a fountain format editor and PDF generator. It’s very easy to use and simple to learn and it works very well with DevonThink, with one exception. I save all the fountain files in DT and they open in Atom with no having to save back a new copy or any of that nonsense. It’s all saved in DT and showing in Atom which sometimes seems like a magic trick.

The exception is this:
In Atom you can’t choose where the PDF is exported/saved to. It automatically saves to the same folder as the fountain file, which in this case is inside the database file.
Now I know messing around with the database file is not advisable so I was wondering what the risk is if a PDF file gets written to a folder inside the database for a minute or two before I move it out to a more sensible place and eventually add to DT the more conventional way.

Summing up: is this crazy koo koo bananas dangerous or “just” a little bit dangerous as long as I don’t move the wrong thing?
Hope I explained this sufficiently well.

How do you export from Atom? Via a package (which one)?

BTW I recently downloaded Atom because I stumbled across this article Navigate your code like it’s 2021. Had no time to test it yet but the Atom package code-ribbon that’s mentioned there seems to be really nice.

I use the Fountain package which has three commands one of which I forget and the other two are PDF preview and PDF export.
Preview makes a PDF to view but it’s not saved anywhere. It can be repeatedly updated after editing the source text.
Export makes a PDF in the database folder where the fountain file is located. If you Export a second time it will ask you if you want to overwrite the file that’s already been created. There isn’t a normal file save dialogue anytime you do an export, it just makes a file and opens it in Atom.
Atom is generally not a classic Mac app and doesn’t conform to all the user interface standards of a lot of good MacOS apps. But it does handle fountain very well and is easy to use for that purpose.

Try this.

It would be possible to first search for a PDF and delete it but it’s probably easier to manually delete what you don’t need anymore.

-- Import Fountain preview PDF

tell application "System Events"
		set theFiles to files of folder ((POSIX path of (path to home folder)) & "/.atom/packages/fountain/temp/") whose name starts with "(preview)"
		if theFiles = {} then error "No preview PDF available"
		set thePath to POSIX path of (item 1 of theFiles)
	on error error_message number error_number
		if the error_number is not -128 then display alert "System Events" message error_message as warning
	end try
end tell

tell application id "DNtp"
		import thePath to (display group selector)
	on error error_message number error_number
		if the error_number is not -128 then display alert "DEVONthink" message error_message as warning
	end try
end tell

The file will be orphaned if you save into the internals of the database.
While this won’t corrupt your database, it is inadvisable.

If you’re going to be using an external editor in this fashion, it may be better to index an external folder for the particular project you’re working on.

Indexing? I’ve avoided dealing with that due to heavy DTTG usage and reading peoples struggles with it on this forum. I have an iOS shortcut that makes a fountain file in DTTG with a basic title page and some writing prompts. I can see if it would work to make that file in an indexed iCloud folder.

I do move the orphan PDF out of the database folder almost immediately.

So 95% of my workflow works perfectly well. DevonThink does everything it should and is a great way to organize scripts in the same place as producers notes, production plans, and all the sundry bits and bobs that belong together.
Atom is great for editing fountain on MacOS and I wish there was an equivalent iOS editor.
(here’s where I plug my idea that the DevonThink company should buy/acquire/invest in the guy behind Editorial and Pythonista, then build Editorial into DTTG as the text editor. I say this with no knowledge whatsoever about how hard this would be or whether any of the people involved want to do it)
I’ve been searching for a way to change the default behaviour via Atom support etc. No luck so far.

Indexing is a good and useful thing. You just have to be more thoughtful about it and understand the interaction between DEVONthink and the original files in the Finder.
However, it’s just one suggestion.

If you want to do a safe Save from the external application, save to the Global Inbox, not the database’s internals.

Or if this is an existing document you’re going to modify: copy it in DEVONthink first, modify the name, then open it in the external editor, and edit away!

You might want to raise a Github issue in the repository for the Atom extension. That’s the appropriate “support channel”, I’d think.

The problem is a single line

 outputFullPath = path.join("#{if isPreview then packageTempPath else parsedPath.dir}", "#{if isPreview then '(preview) ' else ''}#{}.pdf") 

in a single file, and the author(s) of the extension have already provided for some preferences in an external file. They could add one for the directory to save the PDF to.

Alternative 1: You create a fork of the repository and change the line yourself to export to a fixed directory. Not elegant, but solves the problem

Alternative 2: You figure out where the PDF preview stores its temporary file and move that file to where you want it before closing the preview. That seems to be “temp” under the fountain package path itself. Shouldn’t be too hard to find.

Maybe you should have a look at Drafts. It is highly customizable and scriptable.

  • Is this a better Markdown editor then any other (except for the fact that it seems to understand fountain, which is not a widely used dialect)? I’m asking because I’ve tried my share of them on macOS, and I found every single one of them lacking in some aspect.
  • Does this editor exist for macOS as well? If not, would it be wise to have different MD editors on iOS and macOS?

Ehhm … That’s exactly what my script does :wink:

1 Like

Ehhm … You know, AS is always so chatty, I tend to overlook the important parts. Seriously, I didn’t notice that you were talking about the previews in your post.

One could probably even use a Folder action for that, I suppose?


Should be possible, but I’ll leave that for someone else.

@SlickSlack did you try the script? With it (or a modified version, see chrillek’s suggestion) it’s possible to import the preview PDF. In this case there’s no indexing necessary.

Why are you scripting this?

Ah, you two have not yet met? Jim, may I introduce you to @pete31? Pete scripts.


I also script… when it makes sense to (for public offerings).

I didn’t want to suggest indexing because it is (as you mentioned) nothing that should be done without thought. So the easiest way to solve the problem seemed to be a little script. @SlickSlack can of course just use the temp path and import the PDF manually (or duplicate it somewhere). There’s no need to script this, it’s just this hammer and nail thing, you know :wink:

(Although in this case I really can’t think of an easier way to do it …)

I go away for a day and all this happens. Thanks for everyone’s input.

Can’t say I’ve tried as many as you as I am looking specifically for Fountain capable ones. My suggestion was somewhat facetious as I had read a long thread Twitter about the developers’ difficulty focusing on Editorial despite it’s great reviews. He’s also German so I was half jokingly suggesting they could help a fellow German guy out and save a well reviewed text editor during a period where we have heard a lot about their goals of improving the iOS text editing experience.

It does not. I am not up to speed on the differences between the DevonThink iOS and MacOS text editor and the nuances within. Being uninformed in this way allows me to make as many unfounded suggestions as I see fit :stuck_out_tongue_winking_eye: :innocent:

interesting idea. Avoid the whole exporting part. That’s what @pete31’s script does I see.

No Fountain there yet but it does look like an interesting set of apps

It should be noted here that I am not a professional scriptwriter so I have been trying to “roll my own” solution without buying an expensive software package ($Final $Draft!!) to do this thing that is very very slowly growing to take over my non-working life. Slugline is a iOS/MacOS fountain capable editor that would probably do the trick but I have avoided putting any money into this until it generates some money (ha!). But at a certain point it becomes time-expensive trying to avoid spending a little bit of $$, so I may just buckle down and go with a paid solution.

Before you do that I suggest you try Atom with the code-ribbon package. It’s probably very handy to be able to easily see different parts of your screenplay while writing.

What I LOVE about the DevonThink to Atom/Fountain workflow is that the actual writing is done in just a plain text editor. No distractions, no clutter, no notifications or other windows, and did I mention no distractions?
Back in DevonThink is all my scratchings and notes and ideas and the distractions that are at least somewhat connected to the current project and behind DT is EVERYTHING ELSE THAT WANTS TO GRAB MY ATTENTION. So for me, at least, I like to set it up with DT, at close to full screen size, in the background, open to a group of related notes and files, then I open the current script revision in Atom and make it full screen, with the preview PDF to one side, and get to it. I can command-tab to DT to read something or copy and paste into the script but when I command-tab back to Atom I am right where I was before, at the coal face, if you will.
Other solutions that I’ve tried have outliners and note trackers etc but they can make it too easy to bounce around in the script and lose your place.
Admittedly this is just me trying to manage my time and attention and using some free tools (Atom with Fountain) I have found to work with the paid tools I was already using (Devonthink).

If I have any success at this I am sure I will have to learn the collaborative tools that one has to use to work with other professionals. No one is betting heavily on that happening soon and I can cross that bridge when I come to it, then burn the bridge and try to cross it again with fireproof shoes on because, why not?

Thinking about all this reminded me of when I went through all the different options at the beginning of this project.
Slugline and Scrivener are the leading paid options that both have MacOS and iOS apps. At the time the issue for me was figuring out if they could do the basic thing I need which is keep the main script in DevonThink/DTTG without having to do any Save/Import/Reimport gymnastics.

Slugline (free up for to six pages) on MacOS works just like Atom but I balked at buying the iOS version at the time.

I know a lot of people here use Scrivener and I would have given it a shot but it seemed overly complicated at the time and not free so I kept searching.

I think we’re entering TMI territory so I’ll end this here.

I too love Editorial on iOS for it’s simplicity and power and second your motion for Devon Tech to rescue it from neglect. Likely it still functions simply due to its simplicity.

I think you’ll find that fountain is more than sufficient to write screenplays professionally (fountain is I believe the brainchild of screenwriter Jon August).

I too use Scrivener for all kinds of writing - the multi pane window layout is very useful for writing with open reference materials. It also works with Aeon Timeline, and of course Devonthink. Occasionally I try new workflow forks but end up back in Scrivener.

If I would be asked for any advice (I realize I wasn’t) I’d say focus on the work, not the tools, and that as soon as your problem of producing PDFs is solved you’ll have a great low distraction way to get work done.

Thanks for letting me ramble on.