Is there a way to externally tell scrivener to sync?

I’m a programmer working on writing, and am just getting into scrivener. I’m wondering if there is any way for other programmers to tell scrivener to sync? In an ideal world, I’d like to be able to connect my metadata and contents from the inspector to external apps and tools that I hack up in python. My understanding is that they can read the scrivener files and do what they will, and that when I re-enter scrivener I must ask for a sync. I’m hoping I can automate this somehow.

thanks
iain

Are you directly editing the Scrivener project files, or are you editing files from Scrivener’s External Folder?

The first is completely unsupported and presents a very high risk of data corruption, for example if you break the connection between Scrivener’s master index file and the actual contents of the project. On the other hand, since you’re working directly with the live project, no synchronization step is needed.

If you’re using the External Folder feature, Scrivener will automatically check the external folder for changes when you load the project. You should only need to sync manually if the project was open when the external changes were made.

Katherine

Thanks Katherine. To clarify, I’m hoping there is some way to programmatically tell an open scrivener project to sync, so that if a helper app is open at the same time one can do make an external change and have it reflected in scrivener right away.

Sync with what?
I think you need to clarify what you mean.

Scrivener automatically saves any changes made to the project every few seconds, i.e. it saves those files that are affected. “Sync with external folder” means that Scrivener exports the text parts of a project to another folder as .rtf files, and import them again to the project the next time you open the project in Scrivener.

So exactly what is it you want to do?

Ok, I thought I was clear, but I guess not. This is common with programming IDE, like Intellijels. I can use other programs (scripts, etc) to change files that I have open in intellijel. Intellijel has a process watching those files, and will, when I tab into the same file in an intellijel window, either load changes from the file system if it’s safe to do so or popup a window to ask me if I want to overwrite the file system with the current contents or load from disk. A simpler version of the same is to have a sync feature whereby app 1 can be told externally to reload contents from the file system when app 2 has changed them.

So what I want to do: be able to load metadata and notes into other non-scrivener editors, make changes, and tell scriviner to load those changes when I go back to scrivener. My understanding, perhaps incorrect, is that I can do this by manually telling scrivener to syn or reopen the project. What I’m asking/hoping, is that there is some way to have scrivener automatically do it, or receive a signal to do it.

hope that clarifies it

There is no “safe” way to edit a Scrivener project with any tool other than Scrivener itself. What you are proposing is not supported and is extremely likely to cause data loss.

Katherine

"Sync with external folder makes it possible to edit the text, nothing else.

Why would you want to edit metadata and notes in another app?

Yeah, as noted this isn’t quite like an IDE in that the front-end is basically an elaborate multi-file editor. The component files in a Scrivener project are better thought of as being internal chunks of data in a database or something—it would be like hacking OneNote files while OneNote was open. The fact that we use easy to read standard formats and XML is meant more as a failsafe in case of catastrophic failure or a loss of Scrivener, than an invitation to edit the files directly.

So there is no “sync” that causes the software to rescan the component files. The closest thing would be holding down the Option key on the File menu and selecting the tool to rebuild the search index. That is one thing that definitely will get out of true if the file system is modified externally—but the way Scrivener works with the filesystem means there is no safe way to do what you describe. Some files will be held in memory, and if they are edited externally those edits will be blown away when the project is closed. Additionally although we do use standard formats like RTF, we do use some nonstandard coding within them that could be lost. Footnotes, linked images, etc.

The way to “force Scrivener to sync” is to shutdown the app and launch it again. This is not as painful as it may seem because Scrivener launches quickly and does a very good job of restoring your window state to the way they were when you exited. I do it programmatically with shell commands:

# Shut down scrivener osascript -e "quit app" Scrivener
Now the project’s .scrivx file is guaranteed to be in sync. You can walk the XML, access rtf files, etc. Then when you’re done:

# Start scrivener back up again osascript -e "launch app" Scrivener

Because Scrivener isn’t scriptable and has no API, and there are useful things it can’t do, or does only painfully via some cumbersome manual process.

For example, one might wish to roll all documents back temporarily to a given snapshot, compile, and then roll everything forward again to the latest version. Or, suppose you had forgotten to create a snapshot, but you did made a backup .zip file, and would now like to import all documents from that backup as a named snapshot to matching files in your current project. These are just two things I personally have had occasion to do. They are both fairly straightforward in a scripting language like Perl or Python, whereas doing them manually in the Scrivener UI is both tedious and error prone.

I know this is an old post, but I’d like to heartily echo the previous poster’s sentiments. The fact that it’s not scriptable is a pain in the butt. There are a lot of things I’d like to be able to do externally with the metadata.

But the number one thing is to simply edit it all in one place without the hassle and slowdown from scrivener. Manual editing in the outliner is S-L-O-W… did I mention it’s slow?? It’s slow. And tedious. It would be nice to pull it into Excel (or whatever), do the edits, and then feed it back to Scrivener at the very least.

One other nice thing that would be great if you all would add it, would be a full-page “form”-like editor where you could edit all the metadata for a document in one, large, easy-to-read, not-cramped or jammed-up, data form… that wasn’t slow. (Hint: Dropdowns are painfully slow, and have the extra added issue of sometimes changing when you hover over them and roll your mouse wheel).

It would also be nice to be able to reference document metadata inside the document, since it generally is static content anyway. Obviously the non-static (dynamic) fields could be problematic, but you could skip those.

Scrivener should not be slow. How big is the project you’re trying to manipulate?

For the example the poster gives of being able to selectively roll back changes, Scrivener 3 contains an Import and Merge function for that sort of situation.

For general purpose metadata editing, though, it’s possible that Scrivener is simply not the right tool for what you’re trying to do.

Katherine

From what you write I think it would be best if you found a different tool for storing “static” content with rich meta-data. I use DEVONthink for that. I store the “finished” Scrivener documents there. Scrivener is a writing tool. DEVONthink. is a document storage/mgmt/etc tool. Both are fit for purpose.

Sadly, DevonThink (which I also love) is Mac only, and the poster you’re responding to appears to be using Windows.

Katherine

oh dear. good catch.