Importing existing files into Scrivener

I have several thousand files (individual chapters for books) containing about 10,000,000 (yes, ten million) words. They were formatted for easy uploading to a story site, using _ for italics and * for bold. Is there any way to automate converting something like this:

Born to Run is a song by Bruce Springsteen which I love

to this:

Born to Run is a song by Bruce Springsteen which I love

Or a way to use Find/Replace to achieve this. I realize I can manually fix these, but given the amount of text, I’m not sure that’s something I could reasonably undertake.

I can, if necessary, pre-process the text files before import. I’ve already built a script to get them into the correct folder structure on import, with correct chapters titles, so additional massaging is not an issue.

Thanks in advance for any suggestions.

The Markdown importer should do this automatically. Obviously I’d recommend testing with a representative sample, rather than trying to bring in all ten million words in one chunk.

Katherine

When I go to ‘File/Import/Files’ I do not see an option for Markdown. I changed the name of a file to xx01.md (was xx01.txt) and selected it. It was imported ‘as is’ without the text surrounded by ‘’ characters being converted to Italics. I tried changing the '’ to ‘#’ and ‘*’ to see if that had any effect, and I still get the text markings.

Nothing I tried worked. Am I missing something?

As far as I can tell, markdown conversion is only available as an option when using the File > Import… > Import and Split… command. As such, it can only be used for one file at a time. That doesn’t seem appropriate for your use case containing thousands of files. You may have to automate this somehow.

Since they’re text files, it shouldn’t be hard to concatenate them outside of Scrivener, embedding the original filenames (with Markdown tags). Then Import and Split will use the tags to disassemble them again.

What is your ultimate goal for this material, though? There are plenty of tools that are better at bulk manipulation of thousands of text files than Scrivener is.

Katherine

My goal is to get all of my writing into Scrivener. I still update the older stories (typo correction, fixing continuity errors, etc,) and then be able to generate PDF, mobi, docx, and ePub files.

I’ll have to play around with ‘Import and split’ because the way my stories are structured (and I have this working perfectly in Scrivener) is a folder for each chapter, and then a file for each scene. Right now, I have a script which creates the splits because I couldn’t get ‘Import and split’ to do what I wanted. That includes correct chapter titles and scene titles (based on dates).

Literally everything is perfect (and the output is gorgeous) except for being able to covert the ‘_’ and ‘*’ characters.

I can see one potential problem. The standard Markdown for bold is double asterisks like this or double underscores like this. You may wish to test Scrivener’s markdown conversion to be sure it does what you want.

Well, nothing seems to work. I tried the double underscores/asterisks. I tried using ‘Import and Split’

FYI, I’m on MacOS Mojave and have the latest updates to Scrivener.

When you try Import and Split, after you click on the file you want to import but before you click OK, there should be an “options” button in the lower left of the import dialog. Try clicking that. You should have an option to use Markdown headers for splitting. When you select that, then there is a checkbox below for converting Markdown.

It’s annoyingly obscure. :frowning:

Thanks. That seems to solve the italics and bolding issue. I played around with the scene headers (which are dates) and I can’t seem to get the markdown headers to work. I tried the #/## style as well as the ====, ----- style and neither seem to do what I want. I would like the following binder layout from import:

Chapter Title
Scene 1
Scene 2
Chapter Title
Scene 1
Scene 2

The text files are set up with a main title as the first line and as the filename, and the scenes each have a title. Any thoughts? I can easily script changes to the files (and will need to do that to get proper paragraph separators).

My current workflow does the above using the general import feature, but obviously doesn’t convert the italic and bold.

As far as I know, what you’ll need to do is merge all those files and folders into a single file that looks something like this:

[code]# Chapter Title

##Scene 1

[Scene 1 contents]

##Scene 2

[Scene 2 contents]

Chapter Title

##Scene 1

[Scene 1 contents]

##Scene 2

[Scene 2 contents]
[/code]
Then the Import and Split command will create your hierarchy accordingly.

I actually figured everything out today. The problem with the chapters/scenes was that my word processor was using Unix line endings. I wrote a mix of perl, bash, awk, and sed to get the files into the correct format and everything is working.

Woot! :smiley: