in reply to Problem with Renaming script
Apart from that, it might make more sense to set this process up as a "filter" that will create a new set of files, rather than as an "in-place edit" that will relocate and then modify the files.
(The filter approach just seems safer -- if you find problems with what the program does, just fix it and run it again, because the original files that it used as input the first time are still where they used to be, and will still have the same contents they originally had, when you run it again.)
To summarize (in pseudo-perl):
It shouldn't need to be any more complicated than that (except maybe the initial part of finding the files and subdirectories, but I gather you already solved that part).locate the source directory and get the list of files there establish the name of the destination directory, and create it if nec +essary if $source_dir has subdirectories { create them as needed in the $dest_dir } for $infile ( @sourc_files ) { $outfile = $infile; $outfile =~ s{$source}{$dest}; # might be unnecessary? open(IN,"<","$source_dir/$infile"); open(OUT, ">","$dest_dir/$outfile"); while (<IN>) { s/$source/$dest/g; print OUT; } close IN; close OUT; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Problem with Renaming script
by kirk123 (Beadle) on May 22, 2003 at 15:49 UTC | |
by graff (Chancellor) on May 22, 2003 at 17:59 UTC |