View Single Post
Old 10-08-2010, 10:11 AM   #21
bill_mchale
Wizard
bill_mchale ought to be getting tired of karma fortunes by now.bill_mchale ought to be getting tired of karma fortunes by now.bill_mchale ought to be getting tired of karma fortunes by now.bill_mchale ought to be getting tired of karma fortunes by now.bill_mchale ought to be getting tired of karma fortunes by now.bill_mchale ought to be getting tired of karma fortunes by now.bill_mchale ought to be getting tired of karma fortunes by now.bill_mchale ought to be getting tired of karma fortunes by now.bill_mchale ought to be getting tired of karma fortunes by now.bill_mchale ought to be getting tired of karma fortunes by now.bill_mchale ought to be getting tired of karma fortunes by now.
 
Posts: 1,451
Karma: 1550000
Join Date: Sep 2008
Location: Maryland, USA
Device: Nook Simple Touch, HPC Evo 4G LTE
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

Last edited by bill_mchale; 10-08-2010 at 10:14 AM.
bill_mchale is offline   Reply With Quote