Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Software > Sigil

Notices

Reply
 
Thread Tools Search this Thread
Old 02-06-2011, 09:14 PM   #1
Spotnik
Member
Spotnik began at the beginning.
 
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.
Spotnik is offline   Reply With Quote
Old 02-06-2011, 11:28 PM   #2
DaleDe
Grand Sorcerer
DaleDe ought to be getting tired of karma fortunes by now.DaleDe ought to be getting tired of karma fortunes by now.DaleDe ought to be getting tired of karma fortunes by now.DaleDe ought to be getting tired of karma fortunes by now.DaleDe ought to be getting tired of karma fortunes by now.DaleDe ought to be getting tired of karma fortunes by now.DaleDe ought to be getting tired of karma fortunes by now.DaleDe ought to be getting tired of karma fortunes by now.DaleDe ought to be getting tired of karma fortunes by now.DaleDe ought to be getting tired of karma fortunes by now.DaleDe ought to be getting tired of karma fortunes by now.
 
DaleDe's Avatar
 
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.
DaleDe is offline   Reply With Quote
Advert
Old 02-07-2011, 12:52 AM   #3
Spotnik
Member
Spotnik began at the beginning.
 
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.
Spotnik is offline   Reply With Quote
Old 02-07-2011, 01:01 AM   #4
DaleDe
Grand Sorcerer
DaleDe ought to be getting tired of karma fortunes by now.DaleDe ought to be getting tired of karma fortunes by now.DaleDe ought to be getting tired of karma fortunes by now.DaleDe ought to be getting tired of karma fortunes by now.DaleDe ought to be getting tired of karma fortunes by now.DaleDe ought to be getting tired of karma fortunes by now.DaleDe ought to be getting tired of karma fortunes by now.DaleDe ought to be getting tired of karma fortunes by now.DaleDe ought to be getting tired of karma fortunes by now.DaleDe ought to be getting tired of karma fortunes by now.DaleDe ought to be getting tired of karma fortunes by now.
 
DaleDe's Avatar
 
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:
Originally Posted by Spotnik View Post
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.
Are they really html files or txt files? If they are html make sure they all have a html extension. Only one file type can be converted.

Dale
DaleDe is offline   Reply With Quote
Old 02-07-2011, 05:01 AM   #5
Perkin
Guru
Perkin calls his or her ebook reader Vera.Perkin calls his or her ebook reader Vera.Perkin calls his or her ebook reader Vera.Perkin calls his or her ebook reader Vera.Perkin calls his or her ebook reader Vera.Perkin calls his or her ebook reader Vera.Perkin calls his or her ebook reader Vera.Perkin calls his or her ebook reader Vera.Perkin calls his or her ebook reader Vera.Perkin calls his or her ebook reader Vera.Perkin calls his or her ebook reader Vera.
 
Perkin's Avatar
 
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.
Perkin is offline   Reply With Quote
Advert
Old 02-07-2011, 11:16 AM   #6
Ahmad Samir
Zealot
Ahmad Samir , Klaatu Barada Niktu!Ahmad Samir , Klaatu Barada Niktu!Ahmad Samir , Klaatu Barada Niktu!Ahmad Samir , Klaatu Barada Niktu!Ahmad Samir , Klaatu Barada Niktu!Ahmad Samir , Klaatu Barada Niktu!Ahmad Samir , Klaatu Barada Niktu!Ahmad Samir , Klaatu Barada Niktu!Ahmad Samir , Klaatu Barada Niktu!Ahmad Samir , Klaatu Barada Niktu!Ahmad Samir , Klaatu Barada Niktu!
 
Posts: 114
Karma: 5246
Join Date: Jul 2010
Device: none
If you're running Linux you combine all the txt files using 'cat'.
Ahmad Samir is offline   Reply With Quote
Old 02-07-2011, 11:42 AM   #7
Spotnik
Member
Spotnik began at the beginning.
 
Posts: 10
Karma: 10
Join Date: Sep 2010
Device: nook
Quote:
Originally Posted by DaleDe View Post
Are they really html files or txt files? If they are html make sure they all have a html extension. Only one file type can be converted.

Dale
Thanks--I was talking literally about .txt files. Sigil will open and convert a single text file as the first Section####.xhtml file. It seemed logical to me that, if someone were prepping for a project like this that creating separate text files BEFORE importing (since they are going to be separate chapters anyway, right?) would be the way to go, and that you would import each .txt file as the subsequent Section####.xhtml.

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!
Spotnik is offline   Reply With Quote
Old 02-07-2011, 11:45 AM   #8
Spotnik
Member
Spotnik began at the beginning.
 
Posts: 10
Karma: 10
Join Date: Sep 2010
Device: nook
Quote:
Originally Posted by Perkin View Post
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.
This actually does seem to work--it also revealed a flaw in my text files. Notepad apparently has added extraneous characters that show up as boxes in the converted file. They're probably line feeds, or some such. If anyone knows of a good Unicode compliant text editor that doesn't do this I'd be grateful.
Spotnik is offline   Reply With Quote
Old 02-07-2011, 11:47 AM   #9
Spotnik
Member
Spotnik began at the beginning.
 
Posts: 10
Karma: 10
Join Date: Sep 2010
Device: nook
Quote:
Originally Posted by Ahmad Samir View Post
If you're running Linux you combine all the txt files using 'cat'.
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!
Spotnik is offline   Reply With Quote
Old 02-07-2011, 11:57 AM   #10
theducks
Well trained by Cats
theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.
 
theducks's Avatar
 
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:
Originally Posted by Spotnik View Post
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!
in DOS (cmand prompt) Help copy:
Code:
To append files, specify a single file for destination, but multiple files
for source (using wildcards or file1+file2+file3 format)
theducks is offline   Reply With Quote
Old 02-07-2011, 11:58 AM   #11
st_albert
Guru
st_albert gives new meaning to the word 'superlative.'st_albert gives new meaning to the word 'superlative.'st_albert gives new meaning to the word 'superlative.'st_albert gives new meaning to the word 'superlative.'st_albert gives new meaning to the word 'superlative.'st_albert gives new meaning to the word 'superlative.'st_albert gives new meaning to the word 'superlative.'st_albert gives new meaning to the word 'superlative.'st_albert gives new meaning to the word 'superlative.'st_albert gives new meaning to the word 'superlative.'st_albert gives new meaning to the word 'superlative.'
 
Posts: 696
Karma: 150000
Join Date: Feb 2010
Device: none
Quote:
Originally Posted by Spotnik View Post
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!
Well, it's been a while since I HAD to use MS-Dos, but I think the copy command can be used to concatenate files as well.

Details left to the student as an exercise.
st_albert is offline   Reply With Quote
Old 02-07-2011, 11:58 AM   #12
Perkin
Guru
Perkin calls his or her ebook reader Vera.Perkin calls his or her ebook reader Vera.Perkin calls his or her ebook reader Vera.Perkin calls his or her ebook reader Vera.Perkin calls his or her ebook reader Vera.Perkin calls his or her ebook reader Vera.Perkin calls his or her ebook reader Vera.Perkin calls his or her ebook reader Vera.Perkin calls his or her ebook reader Vera.Perkin calls his or her ebook reader Vera.Perkin calls his or her ebook reader Vera.
 
Perkin's Avatar
 
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)
Quote:
Originally Posted by Spotnik View Post
If anyone knows of a good Unicode compliant text editor that doesn't do this I'd be grateful.
I personally use EditPad Pro (Full version, there is a lite free version).
But a couple of other good (free) ones are
Notepad++
PSPad
Crimson Editor
Perkin is offline   Reply With Quote
Old 02-12-2011, 03:24 PM   #13
Faster
Connoisseur
Faster is a glorious beacon of lightFaster is a glorious beacon of lightFaster is a glorious beacon of lightFaster is a glorious beacon of lightFaster is a glorious beacon of lightFaster is a glorious beacon of lightFaster is a glorious beacon of lightFaster is a glorious beacon of lightFaster is a glorious beacon of lightFaster is a glorious beacon of lightFaster is a glorious beacon of light
 
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
Faster is offline   Reply With Quote
Old 02-21-2011, 02:01 PM   #14
grumbles
Addict
grumbles ought to be getting tired of karma fortunes by now.grumbles ought to be getting tired of karma fortunes by now.grumbles ought to be getting tired of karma fortunes by now.grumbles ought to be getting tired of karma fortunes by now.grumbles ought to be getting tired of karma fortunes by now.grumbles ought to be getting tired of karma fortunes by now.grumbles ought to be getting tired of karma fortunes by now.grumbles ought to be getting tired of karma fortunes by now.grumbles ought to be getting tired of karma fortunes by now.grumbles ought to be getting tired of karma fortunes by now.grumbles ought to be getting tired of karma fortunes by now.
 
grumbles's Avatar
 
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>&nbsp;</p>';

WriteLn(OutFile, InBuff);

End;

Close(InFile);

WriteLn(OutFile, '</body>');

WriteLn(OutFile, '</html>');

Close(OutFile);

End.
grumbles is offline   Reply With Quote
Old 02-22-2011, 04:43 PM   #15
Dillinquent
eBook pro
Dillinquent shares his or her toysDillinquent shares his or her toysDillinquent shares his or her toysDillinquent shares his or her toysDillinquent shares his or her toysDillinquent shares his or her toysDillinquent shares his or her toysDillinquent shares his or her toysDillinquent shares his or her toysDillinquent shares his or her toysDillinquent shares his or her toys
 
Dillinquent's Avatar
 
Posts: 71
Karma: 5634
Join Date: Jan 2011
Location: Hertford, UK
Device: PC, iPad, Kindle, Kindle Fire, Galaxy Ace
Quote:
This actually does seem to work--it also revealed a flaw in my text files. Notepad apparently has added extraneous characters that show up as boxes in the converted file. They're probably line feeds, or some such.
Identify the dodgy glyph in code view then use replace to remove them.
Dillinquent is offline   Reply With Quote
Reply


Forum Jump

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


All times are GMT -4. The time now is 10:31 AM.


MobileRead.com is a privately owned, operated and funded community.