randomfox: (Default)
[personal profile] randomfox
This Perl script renames buff-out.ogf to b###.ogf, where ### is the next higher number after the highest numbered b###.ogf file. It is used for keeping an archive of submitted distributed.net OGR packets.


#!perl -w
use strict;
require 5.004;

use DirHandle;

my $TEMPDIR = 'c:\\temp';

my $dh = new DirHandle $TEMPDIR;
defined $dh or die "Error opening directory $TEMPDIR: $!\n";

my $highnum = 0;
while (defined($_ = $dh->read)) {
    if (/b(\d+).ogf/i) {
	$1 > $highnum and $highnum = $1;
    }
}

my $nextindex = $highnum + 1;
print "Highest = $highnum, Next index = $nextindex\n";

rename "$TEMPDIR\\buff-out.ogf", "$TEMPDIR\\b$nextindex.ogf" 
    or die "Error renaming file: $!\n";

__END__

Profile

randomfox: (Default)
randomfox

November 2012

S M T W T F S
    123
45678910
11121314151617
18192021222324
25262728 2930 

Most Popular Tags

Style Credit

Expand Cut Tags

No cut tags
Page generated Jun. 10th, 2026 09:28 pm
Powered by Dreamwidth Studios