On 14.02.2010 18:22, Marek Stepanek wrote:
Here a Perl solution:
> snip
I already said, I am not a Perl professional. Here a improved version:
#!/usr/bin/perl
use warnings;
use strict;
use File::Find;
my $start_dir = '/Users/path/to/start/folder';
find( \&wanted, $start_dir );
sub wanted {
return unless /\.txt$/;
my $file_name = $_;
my $file_path = $File::Find::name;
open (IN, "+<", $file_path);
my $out = "";
while (<IN>) {
# s/$file_name//; # this is the way back for testing
s/this is file:\s*/$&$file_name/ig;
$out .= $_;
}
seek(IN, 0, 0) or die "can't seek to start of $file_path: $!";
print IN $out or die "can't print to $file_path: $!";
truncate (IN, tell(IN)) or die "can't truncate $file_path: $!";
close IN or die "can't close $file_path: $!";
}
--
___________________________________________
the embassy for talented young musicians
Podium International | Marek Stepanek | [email protected]
http://www.PodiumInternational.org
___________________________________________
--
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 [email protected]
To unsubscribe from this group, send email to
[email protected]
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 "[email protected]" rather than posting to the group.