SHARE
TWEET

gwdatffna.pl

dr_ishmael Oct 23rd, 2011 39 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!perl -w
  2.  
  3. use strict;
  4. use File::Path;
  5.  
  6. undef $/;       # Newlines in files don't mean anything
  7.  
  8. my $ffnafolder = "E:\\gwdat\\GWDat\\ffna"; # Input - the ffna folder that GWUnpacker.exe creates
  9. my $atexfolder = "E:\\gwdat\\ffnaATEX"; # Output - where you want the extracted ATEX files to go
  10.  
  11. if (-e $atexfolder) { rmtree($atexfolder); }
  12. mkdir($atexfolder);
  13.  
  14. my $total = 0;
  15. my @dxtcounts;
  16.  
  17. opendir(DIR, $ffnafolder) or die "can't open folder $ffnafolder: $!\n";
  18. while (defined(my $file = readdir(DIR))) {
  19.         next if $file =~ /^\./; # readdir always generates . and .. entries, skip them
  20.         next if (-s "$ffnafolder\\$file") <= 500; # smallest PNG so far is 540 bytes, skip anything smaller
  21.        
  22.         open (IN, "$ffnafolder\\$file") or die "can't open file $ffnafolder\\$file: $!\n";
  23.         binmode(IN); # so Perl doesn't attempt any automatic charset conversions
  24.        
  25.         my $contents = <IN>;
  26.        
  27.         while ($contents =~ /ATEXDXT3/g) {
  28.                 my $atex = substr($contents, pos($contents)-8);
  29.                 my $atexfile = $file;
  30.                 $atexfile =~ s/ffna/atex/;
  31.                
  32.                 open (OP, ">$atexfolder\\$atexfile") or die "can't open file $atexfolder\\$atexfile: $!\n";
  33.                 binmode(OP); # again, to prevent charset conversion
  34.                 print OP $atex;
  35.                 close(OP);
  36.                 $total++;
  37.         }
  38.        
  39.         close(IN);
  40. }
  41.  
  42. print "$total FFNA/ATEX files extracted.\n";
  43. exit(0);
  44.  
  45.  
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top