Please excuse the clickbait title, but there is definitely a bug (obviously unintended behavior). I want to use Compile for .txt because it simply merges all documents together and preserves all text. But I don't want the .txt extension because LaTeX is expecting .tex.

It is reproducible as follows:

The file myFile.tex already exists in my directory. I want to replace the file, so I select compile as "txt", type the name is myFile.tex. Scrivener says, "myFile.tex already exists. Do you want to replace it?". If I click "Yes", it saves the file as myFile.tex.txt. Notice that it saved the file with a different name than the file that existed, and also a different extension than the one I want. It might also delete the file myFile.tex in the process.

If myFile.tex.txt exists in the directory but not myFile.tex, then I select compile as "txt", Scrivener does not notice that the file already exists. It provides no warning. But it overwrites the file myFile.tex.txt.

This is clearly unintended, because Scrivener checks if a different filename than the file written exists.

Last edited by Tom_Anderson on Wed Aug 16, 2017 6:03 am, edited 9 times in total.

The expected behavior is that the save window will have "txt" selected as default, but if the user types in a different extension, the new extension is subsequently used for checking if the file exists and for saving the file. This is the behavior in Notepad++. It fixes the issue I had earlier because I can save in .txt format with the .tex extension. Notepad++ does not have the bug of checking if a different file exists than the one used for saving.

I do note that some applications such as the default Windows Notepad or TexWorks have "Save as type:". The default is "txt" but there's an extra option "All Files (.)" that when selected will preserve the exact name (and extension) that is shown in the File Name text box. This is another way to fix the issue I had earlier, because I can save in .txt format but use the .tex extension. Notepad does not have the bug of checking if a different file exists than the one used for saving.

Other applications such as Microsoft Word restrict the extensions that can be used to save. Although I don't like such arbitrary restrictions, this is due to engineering choice and not a bug in Word. Also, Word does not have the bug of checking if a different file exists than the one used for saving.

PS: I realise this is not a serious bug, since it is only encountered when trying to use custom extensions, but it would be very nice if it can be fixed by allowing us to compile txt format as a custom extension. I'm sick of manually changing the file extensions in Windows. It will be much better to save the file with the desired name and extension to begin with. I do know that other people are also using Scrivener to manage LaTeX files without using any of the compile tools other than merging the documents together.

MultiMarkdown is useful enough but it makes the process more complicated than it has to be. It's much easier for me to just type the LaTeX and get the LaTeX.

Something that often works for me in similar situations is to put quotation marks around the filename in the Save As dialog, e.g., "myFile.tex". Depending on your Windows version, this should tell it to save using the exact filename specified. Might be worth a try anyway.

DavidR wrote:Something that often works for me in similar situations is to put quotation marks around the filename in the Save As dialog, e.g., "myFile.tex". Depending on your Windows version, this should tell it to save using the exact filename specified. Might be worth a try anyway.

Thanks for the suggestion about quotes but for me using Scrivener on Windows 10, using quotation marks around the filename still gets the bug.

To clarify, the bug is that Scrivener checks if file "myFile.tex" exists, provides a popup (do you want to replace it?) if it exists, and then erases "myFile.tex" (unless the file is locked, it silently ignores the failure), then it writes the file "myFile.tex.txt".

It is very unexpected for a program to check if one filename exists and then write with a different filename. It is clearly a bug.

I can't think of a situation that this unintended behavior would have serious consequences, unless someone is using Scrivener for a business project, but I'd guess that it's a straightforward one to remedy.