Thanks!
For these files:
ls
contacts.1.txt contacts.2.txt contacts.3.txt contacts.txt icc.txt ideas.txt notes (Autosaved) notes.txt shownotes_001.txt shownotes_AllShowsShotList_001.txt
that gives me these results:
ls | perl -F"\." -nae 'push @{$a{$F[0]}},$F[1];END{for $i (keys %a){@n=sort {$a <=> $b}@{$a{$i}};print "$i.$n[0]-$n[$#n].$F[2]"}}'
contacts.txt
-3.notes (Autosaved)
.-.icc.txt
-txt
.shownotes_AllShowsShotList_001.txt
-txt
.notes.txt
-txt
.shownotes_001.txt
-txt
.ideas.txt
-txt
.~/notes/ :
What I really am looking for would be this:
contacts.1-3.txt
contacts.txt
icc.txt
ideas.txt
notes (Autosaved)
notes.txt
shownotes_001.txt
shownotes_AllShowsShotList_001.txt
I found another script:
#!/usr/bin/perl
use strict;
#
# lfrms - list frame ranges
# 1.00 01/12/98
erco@3dsite.com
#
$| = 1;
# MAIN
{
my $dir;
my @curdir = ( "." );
my @dirs = ( $#ARGV == -1 ) ? @curdir : @ARGV;
foreach $dir ( @dirs )
{
if ( $#dirs > 0 ) { print "$dir:\n"; }
my @list = split(/\n/, `ls $dir`);
my @last = "";
my $start;
my $pending = 0;
foreach ( @list )
{
if ( /(.*)\.([0-9]*)\.(.*)/ )
{
# NO MATCH ON LAST NAME? SKIP
if ( $1 ne $last[0] || $3 ne $last[2] || ($2-$last[1]) != 1 )
{
# END LAST RANGE
if ( $last[0] ne "" && $last[2] ne "" )
{
if ( $start == $last[1] )
# JUST ONE FRAME? PRINT IT
{ printf("%s.%s\n", $start, $last[2]); }
else
# RANGE? PRINT AS RANGE
{ printf("[%s-%s].%s\n", $start, $last[1], $last[2]); }
}
# START NEW RANGE
printf("%s.", $1);
$start = $2;
$pending = 1;
}
# SAVE FOR NEXT ITER
$last[0] = $1; $last[1] = $2; $last[2] = $3;
}
}
if ( $pending )
{
if ( $start == $last[1] )
# JUST ONE FRAME? PRINT IT
{ printf("%s.%s\n", $start, $last[2]); }
else
# RANGE? PRINT AS RANGE
{ printf("[%s-%s].%s\n", $start, $last[1], $last[2]); }
}
}
}
That returns this:
contacts.[1-3].txt
Which is close to how I'd like the files listed but unfortunately drops the non-sequential files. Would it be easy to modify that command to include the non-sequential files?
Thanks again for offering that.