Advertisement
easternnl

Script to remove the unused sync_bitmaps from a folder

Nov 10th, 2016
500
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 1.68 KB | None | 0 0
  1. # compile script before running to clean up the pre_cci.c or delete pre_cci.c
  2.  
  3. use strict;
  4.  
  5. my $file;
  6. my $filecode;
  7.  
  8. my $resultcode;
  9. my $count;
  10.  
  11. opendir (DIR, ".") or die $!;
  12. while (my $file = readdir(DIR))
  13. {
  14.                                 # Use a regular expression to ignore files beginning with a period
  15.                                 next if ($file =~ m/^\./);
  16.  
  17.                                 # add to the array                                          
  18.                                 $filecode = $file;
  19.                                 $filecode =~ s/sync_bitmap_//;
  20.                                 $filecode =~ s/\.bmp//;
  21.                                
  22.                                
  23.                                
  24.                                
  25.                                 $resultcode = system("grep $filecode ..\\..\\*.c > nul");
  26.                                
  27.                                 if ($resultcode == 0)
  28.                                 {
  29.                                                 print $filecode . " - FOUND ($resultcode)\n";
  30.                                 }
  31.                                 else      
  32.                                 {
  33.                                                 print $filecode . " - NOT FOUND ($resultcode)\n";
  34.                                                
  35.                                                 print "cmd /c del $file\n";
  36.                                                 system("cmd /c del $file");
  37.                                 }
  38.                                
  39.                                
  40.                                 #push (@files, "$file<br />");
  41.                                 $count++;
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement