forked from Coastal-Imaging-Research-Network/hotm2
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathresequence
More file actions
40 lines (25 loc) · 818 Bytes
/
resequence
File metadata and controls
40 lines (25 loc) · 818 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#!/usr/bin/perl
# resequence: change a group of files with numeric names (00023.png)
# into a sequence from 1 through n. Mostly to keep caltech camera
# calibration toolbox happy. strip off the first file name element
# (00023) and replace with incrementing count.
$count = '000000';
do {
$count = sprintf("%06d", $ARGV[1] );
shift @ARGV; shift @ARGV;
} if $ARGV[0] eq '-s';
@f = sort @ARGV;
&Usage if scalar(@f) == 0;
print "starting new sequence at $count\n";
while( $file = shift @f ) {
(undef, @rest) = split( /\./, $file, 10 );
$new = $count . ".$rest[$#rest]";
print "$file -> $new\n";
rename $file, $new;
$count++;
}
sub Usage {
print "Usage: resequence file1 ...\n";
print " example: resequence *.png\n";
exit;
}