3 ###############################################################################
6 # Author : Chris Koeritz #
7 # Rights : Copyright (C) 1996-$now by Author #
11 # This program renames all of the files in a specified directory to have #
12 # completely lower case names. #
14 ###############################################################################
15 # This program is free software; you can redistribute it and/or modify it #
16 # under the terms of the GNU General Public License as published by the Free #
17 # Software Foundation; either version 2 of the License or (at your option) #
18 # any later version. See: "http://www.gruntose.com/Info/GNU/GPL.html" for a #
19 # version of the License. Please send any updates to "fred@gruntose.com". #
20 ###############################################################################
22 require "filename_helper.pl";
23 require "importenv.pl";
25 # call the primary subroutine to rename the files specified.
31 # takes a list of directories as arguments. all of the files in each
32 # directory are renamed to their lower case equivalent.
35 # go through the list of files passed in.
36 foreach $current (&glob_list(@_)) {
37 if ($current =~ /[A-Z]/) {
38 #print "current is '$current'\n";
39 local $old_name = $current;
40 #print "old name is '$old_name'\n";
41 local $dir = &dirname($current);
42 local $file = &basename($current);
43 (local $lc_name = $file) =~ tr/[A-Z]/[a-z]/;
44 local $new_name = $dir . $lc_name;
45 #print "new name='$new_name'\n";
46 local $intermediate_name = $dir . "RL" . rand() . ".tmp";
47 #print "command A is: rename [$old_name] [$intermediate_name]\n";
48 #print "command B is: rename [$intermediate_name] [$new_name]\n";
49 rename($old_name, $intermediate_name)
50 || die "failed to do initial rename";
51 rename($intermediate_name, $new_name)
52 || die "failed to do secondary rename";