Advertisement
Guest User

Untitled

a guest
Jul 20th, 2017
47
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.70 KB | None | 0 0
  1.  
  2. use File::Find;
  3.  
  4. sub eachFile {
  5. my $filename = $_;
  6. my $fullpath = $File::Find::name;
  7. #remember that File::Find changes your CWD,
  8. #so you can call open with just $_
  9.  
  10.  
  11. if (-d "$filename") {
  12.  
  13. my @files;
  14. my @f;
  15. my $filename;
  16. my $a;
  17. my $i;
  18. my $start;
  19. my $end;
  20.  
  21. chomp $filename;
  22. next if ($filename =~ /^(\.|\.\.)$/);
  23. next if $filename eq "";
  24.  
  25. opendir(IN,"$filename/");
  26. @f = readdir(IN);
  27. foreach $a (@f) {
  28. if ($a =~ /^(.+)\.html$/) { $i =$1; push(@files, $i); }
  29. }
  30. closedir(IN);
  31. $start = $files[0];
  32. $end = $files[-1];
  33. print "$filename: START: $start END: $end\n";
  34. rename("$filename","$start-$end");
  35.  
  36. }
  37.  
  38.  
  39. }
  40.  
  41. find (\&eachFile, ".");
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement