02-06-2011, 09:14 PM | #1 |
Member
Posts: 10
Karma: 10
Join Date: Sep 2010
Device: nook
|
Converting multiple text files to xhtml?
I'm trying to create an epub from a batch of text files. When I open the first one it shows up as the content in the first XHTML file in the text folder. However, everytime I try to open the subsequent text file, it just starts a NEW file. I don't want that. I was expecting to find some way to add each text file to the text folder as the subsequent xhtml file. Obviously, it doesn't work this way! So, how does it work?
I have tried "Add New Item" but this just adds a blank xhtml file. So I try adding an existing item. The text files just go in the Misc. Folder. I can click and drag the text file up to the text folder, but I'm missing the step that converts it to xhtml. Obviously I'm new at ePub creation. However, everything I have read suggests that each chapter should be a separate xhtml file. However, I'm having trouble finding some direction in making this happen. Thanks in advance for any help pointing me there. |
02-06-2011, 11:28 PM | #2 |
Grand Sorcerer
Posts: 11,470
Karma: 13095790
Join Date: Aug 2007
Location: Grass Valley, CA
Device: EB 1150, EZ Reader, Literati, iPad 2 & Air 2, iPhone 7
|
zip your collection and let Calibre create an ePUB and then edit the ePUB in Sigil. It is ok by the way to have multiple files in an ePUB. Using Calibre will save you having to add them one by one.
|
Advert | |
|
02-07-2011, 12:52 AM | #3 |
Member
Posts: 10
Karma: 10
Join Date: Sep 2010
Device: nook
|
Okay, well I tried that. I'm still missing something--when I did the conversion from ZIP to EPUB, only the first text file showed up in the ePUB file--as if the others didn't exist. I didn't see a setting anywhere that referred to multiple files, so I was surprised to see that, even though Calibre recognized all 27 .txt files in the zip, only one of them turned up as an html in the EPUB version.
|
02-07-2011, 01:01 AM | #4 | |
Grand Sorcerer
Posts: 11,470
Karma: 13095790
Join Date: Aug 2007
Location: Grass Valley, CA
Device: EB 1150, EZ Reader, Literati, iPad 2 & Air 2, iPhone 7
|
Quote:
Dale |
|
02-07-2011, 05:01 AM | #5 |
Guru
Posts: 655
Karma: 64171
Join Date: Sep 2010
Location: Kent, England, Sol 3, ZZ9 plural Z Alpha
Device: Sony PRS-300, Kobo Aura HD, iPad (Marvin)
|
A fairly easy, but time consuming way...
Open Sigil, (Should have a blank Section0001.xhtml) Open the first txt file in a normal editor, press CTRL+A (select all), then CTRL+C (copy) Switch to Sigil, make sure cursor is in 'Book View', press CTRL+V (paste) If you want separate 'sections' for each text file, in 'Book Browser' right click and 'Add New Item', then doubleclick on new Section####.xhtml If you want all text files in same 'section' then make sure cursor is at bottom of text (you may need to also press return 1 or two times, so next text is separate from previous text) Repeat for each of your txt files. |
Advert | |
|
02-07-2011, 11:16 AM | #6 |
Zealot
Posts: 114
Karma: 5246
Join Date: Jul 2010
Device: none
|
If you're running Linux you combine all the txt files using 'cat'.
|
02-07-2011, 11:42 AM | #7 | |
Member
Posts: 10
Karma: 10
Join Date: Sep 2010
Device: nook
|
Quote:
As I've found, Sigil will do this with html files, but additional .txt files go in the misc. folder. Furthermore, Sigil will create additional Section files from your converted text by using the Page break command. So, if I had just started out with one big giant .txt, this would have been indicated. Well--now I know! Frankly, I'd prefer to let Sigil create the xhtml file since it will be formatted the way the program wants it. It's all part of the learning curve, I guess! |
|
02-07-2011, 11:45 AM | #8 | |
Member
Posts: 10
Karma: 10
Join Date: Sep 2010
Device: nook
|
Quote:
|
|
02-07-2011, 11:47 AM | #9 |
Member
Posts: 10
Karma: 10
Join Date: Sep 2010
Device: nook
|
Yes...I wish I were in Linux for precisely this reason! I think I've figured out that creating separate files was not the way to go, even though I had hoped to avoid working with a single large file. Thanks, anyway!
|
02-07-2011, 11:57 AM | #10 | |
Well trained by Cats
Posts: 29,800
Karma: 54830978
Join Date: Aug 2009
Location: The Central Coast of California
Device: Kobo Libra2,Kobo Aura2v1, K4NT(Fixed: New Bat.), Galaxy Tab A
|
Quote:
Code:
To append files, specify a single file for destination, but multiple files for source (using wildcards or file1+file2+file3 format) |
|
02-07-2011, 11:58 AM | #11 | |
Guru
Posts: 696
Karma: 150000
Join Date: Feb 2010
Device: none
|
Quote:
Details left to the student as an exercise. |
|
02-07-2011, 11:58 AM | #12 |
Guru
Posts: 655
Karma: 64171
Join Date: Sep 2010
Location: Kent, England, Sol 3, ZZ9 plural Z Alpha
Device: Sony PRS-300, Kobo Aura HD, iPad (Marvin)
|
|
02-12-2011, 03:24 PM | #13 |
Connoisseur
Posts: 61
Karma: 12096
Join Date: Sep 2010
Location: Tasmania
Device: Sony PRS 650
|
You may like to take a look at this for future use:
TXTcollector combine text files into one TXTcollector is a handy tool that allows you to combine multiple text files into a single file. You can specify a directory and the program will scan it for .txt files and create a new, single file, separating the content with a divider of your choice. Zipped download contains Setup file and a very good Read-me file. Freeware size: 686 KB Code:
http://bluefive.pair.com/TXTcollector.zip |
02-21-2011, 02:01 PM | #14 |
Addict
Posts: 238
Karma: 1500000
Join Date: Nov 2009
Location: Toronto
Device: Pandigital Novel (Black), T-2 and 3, Nexus 7
|
Once upon a time I wrote a quick program to convert text files to xhtml. It is just a simple program written in Free Pascal. It assumes that the text file is unwrapped. It add p tags at the start and end of the line, adds the correct header and footer and preserves blank lines. Compiles under Windows and Linux with the current version of Free Pascal. The xhtml has the same name as the text file but with a xhtml extension.
Here is the source Program text2xhtml; Uses sysutils; {$H+} {$I-} Const xmlIntro = '<?xml version="1.0" encoding="UTF-8" ?>'; docType = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">'; Var InFile, OutFile : Text; InBuff : String; Begin If ParamCount = 0 Then Begin WriteLn('Usage : ', ParamStr(0), ' [textfile name]'); Halt(1); End; If Not FileExists(ParamStr(1)) Then Begin WriteLn(ParamStr(1), ' not found...'); Halt(2); End; Assign(InFile, ParamStr(1)); Reset(InFile); If (IOResult <> 0) Then Begin WriteLn('Could not open ', ParamStr(1), ' ...'); Halt(3); End; Assign(OutFile, ChangeFileExt(ParamStr(1), '.xhtml')); ReWrite(OutFile); If (IOResult <> 0) Then Begin WriteLn('Could create output file ...'); Halt(4); End; WriteLn(OutFile, xmlIntro); WriteLn(OutFile, docType); WriteLn(OutFile, '<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">'); WriteLn(OutFile, '<head>'); WriteLn(OutFile, ' <title> - </title>'); WriteLn(OutFile, ' <style type="text/css" rel="stylesheet" >'); WriteLn(OutFile, ' </style>'); WriteLn(OutFile, '</head>'); WriteLn(OutFile, '<body>'); While Not EoF(InFile) Do Begin ReadLn(InFile, InBuff); If InBuff <> '' Then InBuff := '<p>' + InBuff + '</p>' Else InBuff := '<p> </p>'; WriteLn(OutFile, InBuff); End; Close(InFile); WriteLn(OutFile, '</body>'); WriteLn(OutFile, '</html>'); Close(OutFile); End. |
02-22-2011, 04:43 PM | #15 | |
eBook pro
Posts: 71
Karma: 5634
Join Date: Jan 2011
Location: Hertford, UK
Device: PC, iPad, Kindle, Kindle Fire, Galaxy Ace
|
Quote:
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
CSS to "wrap" text between two .xhtml files? | december | Sigil | 28 | 12-06-2013 03:29 PM |
Merge multiple XHTML files at once | gmw | Sigil | 1 | 12-28-2010 02:35 AM |
Error Converting Zip Files w/ Multiple Formats | TheHeartlessHero | Calibre | 2 | 04-10-2010 10:54 AM |
Convert zip with multiple text files to MOBI | mindfire | Calibre | 1 | 03-27-2010 10:19 AM |
Converting multiple HTML files into a single hyperlinked PDF? | Jürgen Hubert | Reading and Management | 6 | 01-11-2010 07:44 AM |