hi andrea!
thank you for your help - it did work. i have some extra problems though.
in the code, i replaced nat with a variable (let's call it $section),
here's my code snippet:
### start of snippet ###
#this is the xml repository where all xml files where residing
chdir $repository;
# section will be a command line parameter
$section = shift;
unlink foreach (<*.*.*>);
my $sort_for_nat_number =
sub { "$a$b" =~ /$section_(\d+).*$section_(\d+)/; $1 <=> $2 };
my @full_files = sort $sort_for_nat_number (<*-full.xml>);
my @files = sort $sort_for_nat_number grep {$_ !~ /full/} (<*.xml>);
rename $full_files[$_-1], $section . "_$_-full.xml"
for (1 .. scalar @full_files);
rename $files[$_-1], $section . "_$_.xml" for (1.. scalar @files);
### end of snippet ###
it doesnt sort. why is it so? did i missed anything?
please help me.
thank you very much.
percy
On Sat, 02 Feb 2002 12:13:55 +0100
"Andrea Holstein" <[EMAIL PROTECTED]> wrote:
|If I understand you correctly, you want to do 3 steps:
|1. Delete all files with double extensions.
|2. Sort the remaining files for their number after nat_.
|3. Rename the remaining files correspondending to the sort place.
|
|Let's try:
|chdir $your_directory; # I assume you're already in the right directory
|unlink foreach (<*.*.*>); # delete all files with dual extensions
|
|# Your sort routine
|my $sort_for_nat_number =
| sub { "$a$b" =~ /nat_(\d+).*nat_(\d+)/; $1 <=> $2 };
|
|# Sort all full files and simple files seperatly
|my @full_files = sort $sort_for_nat_number (<*-full.xml>);
|my @files = sort $sort_for_nat_number grep {$_ !~ /full/} (<*.xml>);
|
|# Now renames
|rename $full_files[$_-1], "nat_$_-full.xml"
| for (1 .. scalar @full_files);
|
|rename $files[$_-1], "nat_$_.xml" for (1.. scalar @files);
|
|
|Best Wishes,
|Andrea
|
|
|
|
|
|
|
|
|--
|To unsubscribe, e-mail: [EMAIL PROTECTED]
|For additional commands, e-mail: [EMAIL PROTECTED]
_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]