SHARE
TWEET

Untitled

a guest Feb 18th, 2020 75 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. $sevenzip = "7z";  #path to 7z.exe from 7-zip program, make sure to use / and not single \ in path
  2. $filetypes = "cbr|cbz|cb7";  #filetypes to test, use | between types
  3. $skipdir = "System Volume Information|$RECYCLE.BIN|corrupt";   #don't scan these directories, use | between names
  4.  
  5. open (OUT, ">>corrupt.txt");
  6. listdir(".");
  7. printf ("%-79s\n", " ");
  8. print "\n--- Done ---\n";
  9. sleep(600);
  10. close (OUT);
  11. exit;
  12.  
  13. sub listdir{
  14.     my ($dir) = @_;
  15.     my ($file, @files, @list);
  16.     opendir(DIR, $dir) || return;
  17.     @files = grep { /^[^.]/} readdir(DIR);
  18.     closedir DIR;
  19.  
  20.     foreach $file(sort(@files)) {
  21.         if (-d "$dir/$file") {
  22.             if (! ($file =~/^$skipdir$/i)) {
  23.                 listdir("$dir/$file");
  24.             }
  25.         } elsif ($file =~ /\.($filetypes)$/i) {
  26.             open (DATA, "$sevenzip t \"$dir/$file\"|");
  27.             @list = <DATA>;
  28.             close(DATA);
  29.             $info = $list[$#list-1];
  30.             if ($info =~ /Sub items Errors: (\d+)/) {
  31.                 if ($1 == 1) {
  32.                     printf ("%-79s\n", substr($file,0,70).": $1 Error");
  33.                 } else {
  34.                     printf ("%-79s\n", substr($file,0,69).": $1 Errors");
  35.                 }
  36.                 print OUT "$dir/$file\t$1\n";
  37.                 if(not (-e "corrupt/$file")) {
  38.                     rename  ("$dir/$file", "corrupt/$file");
  39.                 }
  40.             } else {
  41.                 printf ("%-79s\r", substr($file,0,75).": OK");
  42.             }
  43.         }
  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