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.
|