importing text files with a different extent

I use Scrivener as a laboratory notebook (and it is great for this purpose). Part of this is importing files of a statistical nature. These are command files and output files. They are all text files, but they have a different extent; either name.do or name.log

When I import them, they are not editable.
Why is that?
Do I have to rename them to name.txt before importing them? That is not desirable as some of the files, especially the name.do files are used repeatedly during analysis.

Help.

Thanks

Don

Hi Don,

I’m afraid your assumption is correct - Scrivener does’t know about .do .or .log files and so imports them as files for referencing only, viewing them with QuickLook. The only way to import them currently is to remove their extensions or change their extensions to .txt. It would be a good idea, come to think of it, for me to add .log as a known plain text extension - are .do files always plain text? Looking online they seem to be something to do with Oracle…

All the best,
Keith

I use them in the context of Stata, a popular statistical analysis program. In this context, all .log and .do files are plain text files. I imagine, but cannot substantiate, that .log and .do files are almost always plain text files as.

It would be VERY nice to have .do and .log files importable into Scrivener.
Is there any way for Scrivener to ‘look’ at a file and determine if it is in plain text or not, or does it depend on the extent to determine this. Logically thinking, if a file does not have an extent, Scriv would have to do some scrutiny of the file to determine if it could import it or not.

Thanks for your help and rapid response

Don

Hi,

I’ve added .do and .log to the importable file types, as that seems a safe assumption to make. If a file has no extension, Scrivener just assumes it’s plain text and imports it. There’s no way I know of to examine a file and just know that it’s plain text, given that all files are just streams of data. Maybe someone knows of a way - if they do, let me know! :slight_smile:

All the best,
Keith

Hi,

I’ve added .do and .log to the importable file types, as that seems a safe assumption to make. If a file has no extension, Scrivener just assumes it’s plain text and imports it. There’s no way I know of to examine a file and just know that it’s plain text, given that all files are just streams of data. Maybe someone knows of a way - if they do, let me know! :slight_smile:

All the best,
Keith

There is a way, if you pop out to the command line and use the “file” command:

Jayne:Docs rdg$ file 383.rtf 383.rtf: Rich Text Format data, version 1, ANSI Jayne:Docs rdg$ file 383_synopsis.txt 383_synopsis.txt: ASCII English text, with no line terminators Jayne:Docs rdg$ cp 383.rtf /tmp/383 Jayne:Docs rdg$ file /tmp/383 /tmp/383: Rich Text Format data, version 1, ANSI Jayne:Docs rdg$

I can only assume that there are programming libraries out there that might be available to you to use, but I don’t know if the best ones would be commercially viable (probably GNU).

Edit: According to the wikipedia entry on the Unix file command:

So maybe there’s an objective C interface to /etc/magic or it’s Mac OS equivalent.

Maybe you can, but you lost me in the first line about 'popping out to the command line" etc.
I will wait for the formal product. Scriv is to valuable to me to potentially screw something up.

Thanks anyway.

Don

Keith
Somewhere between your response about adding .do and .log files and the next bit about writing code, I thought I had put in a message regarding when these changes would be made to Scrivener. Would they be in the 3.0 or in one of the pending updates? I am keen to use them but obviously there are other priorities in your life.

I don’t know why my initial response didn’t get to the board. I hope this one does.

Sorry, that was aimed squarely at Keith. Even if you did what I was describing, it wouldn’t help import those files into Scrivener. Sorry for the technical gibber-jabber.

KB, bad idea. Both .log and .do can be binary on all platforms. You can use RG’s file (there is a unix lib extension that will perform the same thing but I can’t recall it as I am a pointy haired boss now) but I would suggest that you let us define file extensions that are willing to define as “text” in a preferences.

In other words, let us break scriv, don’t break it for us.

Might be a candidate for a hidden preference, that one.

Hi Don,

This would have been in the next update, but Jaysen makes a good point - it would be much better to have a user-definable list of extensions in the preferences. That shouldn’t be too hard to add, although it would take a few hours I might not have at the moment, but I’ll put it on the list.

All the best,
Keith

Sorry Don.

Jaysen
Nothing to be sorry about. I think it is a good suggestion. May allow for more flexibility.
I am willing to go along with many comments, as long as I can get Scrivener to do what I want (within the bounds of reason and propriety).

Don