Those disturbingly random folder names


so, there used to be an option that caused Scriv to name the .rtf files in which it stores documents with the same title the document has in the binder.
With Scriv 3, the text files are, each on its own, stored in a folder with a long, randomly generated title that has no connection whatsoever with the position that the document has in the binder.
As a person who sometimes wants to be like "right-click > show package contents > click > click > click > open this document in generic text editor ", this poses a problem, as you can imagine.

How can I make it so that, at least, those documents are in the same order as they are in the binder? Because mostly I need to do the clicky stuff with one of my three newest documents - which now no longer are the three docs with the biggest number, and short of going through every single folder manually, there is no way of finding them.
Ideally - of course - I get the option that I mentioned in the first sentence of this post.

Also, those random folder names are just plain disturbing. I just wanted to mention that. Random names in a random order, and each file in each folder has the same name, it turns my scenes into faceless cogs in an incomprehensible machine. Call me dramatic. It’s just how I feel.
Not that Scriv 3 isn’t awesome, it totally is. But.

Thank you for your help.

No, it has never been possible to use the Binder names in the Scrivener package. You could get them if you exported the files, but not in the live project itself.

Those random folder names facilitate synchronization with iOS Scrivener, ensuring that each file has an identifier that is unique across systems.

Editing files from inside the Scrivener package using any tool other than Scrivener itself is not supported (and never has been) and is (as it has always been) entirely at your own risk.

The supported mechanism for doing this is the Sync with External Folder command.


Ah, yes, I remembered that wrong re: file names when exporting.

And I know that I play around inside .scriv packages at my own risk; this is why I have four backups - two of which are manual - so that I can fuck up as much as I want without losing any data :slight_smile:
Still, there has to be a file that stores the info about which binder object belongs to which randomly named folder. I guess I’ll find info on that in Appendix F of the manual?

Yes, the mapping of which files have which unique universal ID (UUID) is in the projectname.scrivx file, which is an XML file that is relatively easy to parse:

<BinderItem UUID="F0A64E33-D01A-4070-BF1A-7DA5DC26D5C8" Type="Text" Created="2018-05-22 11:40:45 +0800" Modified="2018-06-04 13:13:07 +0800">
	<Title>Application Letter</Title>

You could make a script to read the scrivx and create an “index” of which UUID maps to which Binder title.

Thank you for that information! Could you recommend a resource that could teach a complete coding novice how to do this?

There are (I’m guessing) a couple hundred programming languages that can be utilized to read or write XML, none of which are what I’d call ‘novice friendly’. XML parsing is not something I’ve encountered the need (or desire) to learn to code in any of the languages I know well. My advice, though, is to focus on learning a language that makes sense for you, with an eye to gaining the proficiency in that language to make use of XML parser libraries (which probably don’t come pre-installed.)

Since you’re presumably a Mac owner, there are a couple of scripting languages that come installed by default. PERL being one, and I think Python being another. There’s also Applescript and the BASH shell, but I don’t know if the former has XML parsing capabilities, and the later certainly does not. Installing Xcode might expand your options in programming languages without too much pain, so I’d look into that if the Mac is your primary computing platform.

Thanks for your suggestions. I’m beginning to think, though, since I just need to isolate the strings that sit in between ‘UUID="’ and ‘" Type’ / ‘’ and ‘’ from what’s basically just a plain text file I don’t actually need a fancy parser.
I mean, RegEx is what Satan created after he got bored with Smallpox, buttttttt…

I would not bother with the XML parsers. Too much complexity for a beginning coder. It’s easy enough to read the binder file by ordinary string programming. This is a snippet from my code in AutoHotkey (for PC). The called routines look for their anchor strings just as the outer loop does.

Loop { LSeq := A_Index Searchterm := "<BinderItem UUID=" . dquote SearchPos := InStr(ScrivBinder,Searchterm,,LastBinderPos) ; if SearchPos = 0 break ; Gosub, InitSearches Gosub, LocateDocElements Gosub, MakeKeyWords Gosub, FullReferences Gosub, HandleChildren Gosub, SetDocDate }

Rgds - Jerome

macOS has Ruby, Python and PERL built-in. I prefer Ruby (AmberV uses Ruby too), but it will be broadly similar to write a script to use RegEx to parse each line. A skeleton script could look like this (this is a simplified version of a script I use to regex replace sections of an LibreOffice XML file), this reads an XML file and goes through each line looking for a regex, and writing the info to a new summary file:

#!/usr/bin/env ruby
# encoding: utf-8

regex = /svg:width="95%"/
rep = 'svg:width="100%" style:rel-width="100%"'
infilename = ARGV[0]
fail 'Please specify an existing file!' unless infilename && File.exist?(infilename), 'r+') do |f|
	fout = []
	linenum = 0
	lines = f.readlines
	lines.each do |line|
		linenum += 1
		if line =~ regex
			line.gsub!(regex, rep)
			fout.push("Line #{linenum} matched and replaced: #{line}")

	newfilename = filename.gsub(/\.scrivx/,  'SUMMARY.txt'), 'w') do |f|
		puts '===> Trying to write output to ' + newfilename
		fout.each do |line|

You’ll need to modify the logic to remember if uuid matches on linenum, then on linenum+1 record the title into your summary file…

Thanks, both of you, for your scripts! I’ll try to modify/use them. Cross your fingers for this n00b!

EDIT: I managed to figure it out using Atom and some clumsy RegEx:


Then I find-all’d and copied it into a new file and did a quick search/replace for the remaining tags.
I admit, I’m a sucker for quick work arounds :smiley:

(In case of other n00bs: The stuff with the mustache brackets finds the UUID, the stuff after the pointy brackets/title finds the title, and since I’m not searching for line breaks, the line break terminates the search pattern.)

Even more helpful for noobs, an excellent regex tester that details how it works:

and for ruby users:

Actually this shows you there are some errors in your regex (maybe ok for gui search/replace, but not for a script) :stuck_out_tongue:

I would do it like this:

Yeah, as I said: clumy RegEx :wink: - Thanks for the links, though!