AppleScript for switching Preferences for different projects

I like to have some Scrivener projects that use a default font of Courier New, and others that use Times New Roman or sometimes Baskerville. As far as I know there is no way at the moment to make the default font adhere to a .scriv file or to a template - you can load and save Preferences within the Preferences dialog but that’s it. And that’s slow.

So for my own use I’ve created two AppleScripts - one to switch between different Preference profiles, and the other to add, update, or delete such profiles. The effect is achieved by switching between different saved plists in ~/Library/Preferences, making whichever one you request the active plist for Scrivener.

The switcher also launches Scrivener upon selecting a profile. Because the plist remembers the last Scrivener file opened, the effect is to associate a profile with a particular .scriv file as well. For me this works nicely. I launch them from FastScripts but the default Scripts menulet would work nicely too.

If you do not have any plists other than the default, the switcher AppleScript will be empty; use the add, delete, or modify script to add a profile other than the default. Also, if you want to update a Preferences profile, it’s best to use the add, delete, or update script for this purpose - otherwise when you use the switcher script to launch Scrivener, it will trash the Preferences changes - that’s because it restores the previously saved profile.

They have been tested reasonably well but as always with this sort of thing, if you want to try them out, use at your own risk.
Preferences_scripts.zip (21.6 KB)

Now down to a single AppleScript to do everything. The first time used, it will ask you to create a new profile from the existing Preferences plist for Scrivener.
Scrivener Preferences - switch or edit profiles.scpt.zip (18.1 KB)

Very nice, thanks. I’m not an Apple Script writer (yet, I should hope), but am wondering if a script could be written to create profiles in the compile form. I’m seeing the need to compile the same project different ways at different times (for example, compiling just one file instead of the whole thing ((I know, just de-select, but then I must re-select, and I’m getting lazy!)). Would such a trick be possible?

From what I can tell, selections & de-selections for Compile Draft are not saved in the pfile. It might be that the only way of scripting this would be GUI scripting, which is certainly not impossible, but an entirely different labor of love (or hate, depending on how well or badly the scripting is going). I’m afraid I won’t be doing this anytime soon, but if you ever want to try it for yourself, there is an app called UI Browser that is great for helping find out how to script the GUI of something like Scrivener, which is not otherwise scriptable.