Recursively remove .svn folders


/ Published in: Perl
Save to your folder(s)

Can be used on any machine with PERL installed. Just execute this script in the directory and it will remove .svn folders recursively


Copy this code and paste it in your HTML
  1. #!/usr/bin/perl
  2.  
  3. sub cleanup {
  4. my $dir = shift;
  5. local *DIR;
  6.  
  7. opendir DIR, $dir or return false;
  8. for (readdir DIR) {
  9. next if /^\.{1,2}$/;
  10. my $path = "$dir/$_";
  11. unlink $path if -f $path;
  12. cleanup($path) if -d $path;
  13. }
  14. closedir DIR;
  15. rmdir $dir;
  16. return true;
  17. }
  18.  
  19.  
  20. sub cleansvn {
  21. my $dir = shift;
  22.  
  23. cleanup ("$dir/.svn");
  24.  
  25. local *DIR;
  26.  
  27. opendir DIR, $dir or die "opendir $dir: $!";
  28. for (readdir DIR) {
  29. next if /^\.{1,2}$/;
  30. my $path = "$dir/$_";
  31. cleansvn($path) if -d $path;
  32. }
  33. closedir DIR;
  34. }
  35.  
  36.  
  37. cleansvn(".");

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.