[ Index ]

PHP Cross Reference of Unnamed Project

title

Body

[close]

/se3-unattended/var/se3/unattended/install/tools/ -> lower-caseify.pl (source)

   1  #!/usr/bin/perl
   2  
   3  # This scripts renames a folder and of its subfolders to lower case.
   4  # To use this script to fix an OS installation point, simply:
   5  #
   6  # 1) Install ActiveState Perl and associate .pl files with it.
   7  #
   8  # 2) Run "lower-caseify.pl Z:\os\winxpsp2" (or whatever).
   9  
  10  use warnings;
  11  use strict;
  12  use File::Spec;
  13  
  14  sub doit ($);
  15  sub doit ($) {
  16      my ($file) = @_;
  17  
  18      print "Skipping $file\n" if ($file =~ /.*(?:linuxaux|CVS|Unattend|AutoIt\.exe|README\.txt)$/);
  19      return if ($file =~ /.*(?:linuxaux|CVS|Unattend|AutoIt\.exe|README\.txt)$/);
  20  
  21      if (! -l $file && -d _) {
  22          # Directory; recurse through its contents.
  23          opendir DIR, $file
  24              or die "Unable to opendir $file: $^E";
  25          my @contents = readdir DIR;
  26          closedir DIR
  27              or die "Unable to closedir $file: $^E";
  28          foreach my $entry (@contents) {
  29              $entry eq '.' || $entry eq '..'
  30                  and next;
  31              doit (File::Spec->catfile ($file, $entry));
  32          }
  33      }
  34  
  35      # Rename to lower-case.
  36      my $lc_file = $file;
  37      $lc_file =~ s/([^\/]*\/*)$/lc($1)/eg;
  38      $file eq $lc_file
  39          or print "Renaming $file -> $lc_file\n";
  40      $file eq $lc_file
  41          or rename $file, $lc_file
  42          or die "Unable to rename $file to $lc_file: $^E";
  43  }
  44  
  45  foreach my $file (@ARGV) {
  46      doit ($file);
  47  }
  48  
  49  exit 0;


Generated: Tue Mar 17 22:47:18 2015 Cross-referenced by PHPXref 0.7.1