View Single Post
Old 10-08-2010, 12:07 PM   #22
lunixer
Addict
lunixer has learned how to read e-bookslunixer has learned how to read e-bookslunixer has learned how to read e-bookslunixer has learned how to read e-bookslunixer has learned how to read e-bookslunixer has learned how to read e-bookslunixer has learned how to read e-bookslunixer has learned how to read e-books
 
lunixer's Avatar
 
Posts: 231
Karma: 928
Join Date: Aug 2010
Device: Kindle 3
Quote:
Originally Posted by bill_mchale View Post
Assuming the "'" are all coded using the same character, as they would be in a text file like the ones you might get from Project Gutenberg (and likely the epubs and stuff derived from PG), the following perl script will work. Just cut and paste it into a file.

#! /usr/bin/perl
# --- REPLACE the above line with the path to perl on your system (unless windows).
if ($#ARGV != 0) {
print "USAGE replace_single.pl <infile>\n";
die;
}
my ($infile) = @ARGV;

my (@lines) = `cat $infile`;


foreach (@lines) {
s/ '/ "/g;
s/' /" /g;
print "$_";
}

If distinct characters are being used, as would probably be the case with a more professionally formatted book, well, I would need to know the encoding of the characters, but that should be even easier.

P.S. Oh right... at the moment, this script just prints out to Standard Out. You will probably want the output in a file. On a Mac or Linux system you would run the program like this:

replace_single.pl orig_book.txt > new_book.txt (Note the .txt will be replaced with
whatever file extension we are dealing with here).

--
Bill
I ended up writing a macro that does it in MS Word. Doesn't catch everything, but it's good enough. And I always proof the books as I read them on my kindle and just fix them up a bit more when I'm done.
lunixer is offline   Reply With Quote