Use filename when launching files from Research folder

Dear Keith (and the team).

In addition to using Scrivener to write research papers/grants, I have also just started using Scrivener to organise my programming code (mostly R scripting). The “Research” folder seems like a great place to hold all of my scripts in an organised fashion. I can then add research notes to text files on ideas/how things work etc in the regular “Scrivenings” Draft area above.

Now to my feature request: When I launch a “.R” file that is in the Research folder, RStudio launches fine, and the file opens correctly. (Great!) BUT: the filename that Rstudio reads has no meaning: “7.r” for example. I am sure this is because of the way the research files are named/stored within the Scrivener package document.

So…would it be possible for the correct filename to be passed to R? (or indeed to any other external program that gets launched?) Scrivener knows what it is called, but it would be really helpful if the external program did too!

I hope this makes sense, would prove useful to others, and ultimately is something that can be implemented.

By the way, I am running Scrivener 2.7 on OSX 10.8.6

Many thanks for this great piece of software,

Matt

p.s. I apologise if this has been asked before, but my searches drew blanks.

Hi Matt,

Unfortunately this isn’t possible. A .scriv file is really just a package - a special sort of folder - with all the files you import or add stored separately inside it. (This way, if the project gets corrupted in some way - and there are safeguards against that with two backups of the binder in there at any one time - your writing and research is still retrievable. It also means that memory usage is kept to a minimum, because by storing the files individually it can load them into memory only as they are needed.) Inside a .scriv package, all of those files are stored using unique numerical indexes, like in a database. All “Open in External Editor” does is pass those files along to the external editor. There’s no way to to tell an external editor, “Hey, this file is really called x, but please display it as though it’s called y.”

The only way around it would be to save out the file to a temporary copy on disk with the UI name and then open that. However, this would be problematic, because if it’s a 500MB PDF, say, that is going to take a while. And if the user wants to open the file in an external editor to make some edits on the file, then this won’t work because the edits would be on the copy.

So, although I absolutely understand the request and recognise that it would be nicer if files could show their binder names in external editors, it’s just not technically possible, I’m sorry to say, without sacrificing other key features that Open in External Editor provides.

All the best,
Keith

Thanks for your quick response Keith,

Would it not be possible for the documents inside the package to simply retain their original name? (Perhaps appended with the unique Scrivener identifier?) Or are there other reasons to reduce the filename to a simple singular number?

Prepending with a UID would also not be a deal-breaker for me!

Matt

Hi Matt,

Yes, they use unique identifiers so that they can be loaded quickly and so that it doesn’t matter what name they have in the binder - the names in the binder might be disallowed in file names, and also, inside the Scrivener package, they are all kept in a flat list, not hierarchically as in the binder, so the names have to be unique. It also means that Scrivener can find the files instantly, without having to scan through looking for names, and that Scrivener doesn’t have to worry about the name on disk going out of sync with the binder document that represents it if there’s a crash (for instance), because the name is always stable.

Appending the file name internally could make file loading slower, too, because Scrivener would have to try to work out the current name on disk from the ID and the current binder name - which could go out of sync in case of a crash, meaning that Scrivener would have to cycle through all the files in the folder looking for the right prefix to avoid such problems. (In an early version of Scrivener, I tried using file names internally, but it caused lots of problems and limitations.)

All the best,
Keith

Well certainly having a stable solution is important here. I guess the benefit of the current solution is that once created, the filename of the binder document never changes regardless of what the user may do. I don’t personally know how much of a difference this makes to stability, but I can see that it probably doesn’t hurt to have it that way.

I guess a concern might be that an external program might modify the name of the file it has access to. Is that a possibility - even with the current naming scheme?

May I still, however, suggest one very tiny modification?

Could the Research documents be all prepended with “R” (For Research) before the UID number?

This would at least ensure that their (alpha)numerical identifier is relatively low compared to a large Drafts folder (prepended with “D” perhaps?).

Just a thought…It’s not a big deal at all of course…I’m just looking at more and more justifications for using Scrivener…

Matt

Except that the user can move documents back and forth between Research and Draft, so you would have the same issues related to name changing.

Katherine

I hadn’t thought of that…very good point!

What I am actually a little concerned about is using Rstudio to “Save As” a document it has been given access to. The default will be to save back into the Scrivener Package…I can’t imagine this is a good idea…

Before I go ahead and (accidentally) corrupt the package, may I have your thoughts on this Keith?

Matt

If you use “save” rather than “save as,” RStudio should save right back into the original file in the package. Which is fine and the expected behavior.

But no, if you save to a new location from RStudio, Scrivener won’t be able to find the edited version of the file.

Katherine

Thanks Katherine.

Feature request: Would it be possible to enable drag and drop of files from Scrivener to another location? (Desktop or perhaps an email client?) i.e. of Binder items that cannot be viewed directly by Scrivener?

For example, I have the external documents listed in the Binder, and I can very nicely launch them in an external editor. However, what would be really useful is to be able to simply drag the relevant file from the Binder to create a copy of it elsewhere. (For example a way to share research files by email).

This works OK for regular text documents held in Scrivener, but is currently not possible for “external” files. My current workflow for getting access to such a file for sharing is pretty convoluted (open the file in external editor > Save As a new file to Desktop > move from Desktop to Email client > Trash temporary Desktop copy).

Thanks for your time, Matt

You can use the File -> Export -> Files command to eliminate the open externally/Save As steps.

Katherine