At 04:00 -0500 02/09/2011, Christopher Stone wrote:
Save the script as an Applescript and put it in the BBEdit script menu.
Give it a handy keyboard shortcut.
Open your saved 'EN' text file template from the directory you wish
to create the new files in.
Run the script.
Ditto for my script, which now does what it's supposed to
tell application "BBEdit"
tell front document to set _template_mac to its file
set _template to POSIX path of _template_mac
end tell
do shell script "perl -w <<'END_OF_PERL';
use strict;
my @country_codes = qw(DE GB CN
BR KR SE NO TH CL GR);
my $template = qq~" & _template & "~;
open my $fh, qq~<$template~ or die $!;
my @lines = <$fh>; # get the lines of the doc
close $fh;
foreach my $cc (@country_codes){
$_ = $template;
s~(_)(EN)(\\.)~$1$cc$3~; # name the new file
open my $fh, qq~>$_~ or die $!; # create the new file
foreach (@lines){ # loop through the lines
my $modified_line = $_; # making the country code substitutions
$modified_line =~ s~(_)(EN)(\\.)~$1$cc$3~;
print $fh $modified_line; # write the changed line to the new file
}
close $fh
}
END_OF_PERL
"
--END of AppleScript
--
You received this message because you are subscribed to the
"BBEdit Talk" discussion group on Google Groups.
To post to this group, send email to bbedit@googlegroups.com
To unsubscribe from this group, send email to
bbedit+unsubscr...@googlegroups.com
For more options, visit this group at
<http://groups.google.com/group/bbedit?hl=en>
If you have a feature request or would like to report a problem,
please email "supp...@barebones.com" rather than posting to the group.
Follow @bbedit on Twitter: <http://www.twitter.com/bbedit>