Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!perl -w
- use strict;
- use File::Path;
- undef $/; # Newlines in files don't mean anything
- my $ffnafolder = "E:\\gwdat\\GWDat\\ffna"; # Input - the ffna folder that GWUnpacker.exe creates
- my $atexfolder = "E:\\gwdat\\ffnaATEX"; # Output - where you want the extracted ATEX files to go
- if (-e $atexfolder) { rmtree($atexfolder); }
- mkdir($atexfolder);
- my $total = 0;
- my @dxtcounts;
- opendir(DIR, $ffnafolder) or die "can't open folder $ffnafolder: $!\n";
- while (defined(my $file = readdir(DIR))) {
- next if $file =~ /^\./; # readdir always generates . and .. entries, skip them
- next if (-s "$ffnafolder\\$file") <= 500; # smallest PNG so far is 540 bytes, skip anything smaller
- open (IN, "$ffnafolder\\$file") or die "can't open file $ffnafolder\\$file: $!\n";
- binmode(IN); # so Perl doesn't attempt any automatic charset conversions
- my $contents = <IN>;
- while ($contents =~ /ATEXDXT3/g) {
- my $atex = substr($contents, pos($contents)-8);
- my $atexfile = $file;
- $atexfile =~ s/ffna/atex/;
- open (OP, ">$atexfolder\\$atexfile") or die "can't open file $atexfolder\\$atexfile: $!\n";
- binmode(OP); # again, to prevent charset conversion
- print OP $atex;
- close(OP);
- $total++;
- }
- close(IN);
- }
- print "$total FFNA/ATEX files extracted.\n";
- exit(0);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement