JoeCool has asked for the wisdom of the Perl Monks concerning the following question:
Output:opendir(DIR, $path); @files = readdir(DIR); closedir(DIR); $ct = 0; foreach $fname (@files) { if($fname eq ".") { print "Skipped \"$fname\"\n"; next; } # skip t +he current dir if($fname eq "..") { print "Skipped \"$fname\"\n"; next; } # skip +the parent dir if(`-d $fname`) # dir find { print "DIRECTORY: $fname\n"; next; } my $newfname = lc($fname); # if(rename($fname, $newfname)) # { print "Changed $fname to $newfname\n"; } print "FILE[$ct]: \"$fname\" \"$newfname\"\n"; $ct++; }
Notes:Skipped "." Skipped ".." FILE[0]: "AUTORUN.INF" "autorun.inf" FILE[1]: "COPYRGHT.HTM" "copyrght.htm" FILE[2]: "CREDITS.HTM" "credits.htm" FILE[3]: "INDEX.HTM" "index.htm" FILE[4]: "LOADING.HTM" "loading.htm" FILE[5]: "NETRESULTS.BAT" "netresults.bat" FILE[6]: "Network Trash Folder" "network trash folder" FILE[7]: "RUN_ME.SH" "run_me.sh" FILE[8]: "SE32.EXE" "se32.exe" FILE[9]: "index.html" "index.html" FILE[10]: "private" "private" FILE[11]: "smbusers" "smbusers" FILE[12]: "GIFS" "gifs"
Enjoy
Edited by japhy -- please reserve <code>...</code> tags for actual code
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Renaming Sub Dir/Files.
by jryan (Vicar) on Dec 17, 2001 at 08:58 UTC | |
|
Re: Renaming Sub Dir/Files.
by ehdonhon (Curate) on Dec 17, 2001 at 08:49 UTC | |
by TheDamian (Vicar) on Dec 20, 2001 at 05:29 UTC | |
by dmmiller2k (Chaplain) on Dec 17, 2001 at 21:41 UTC | |
|
Re: Renaming Sub Dir/Files.
by rob_au (Abbot) on Dec 17, 2001 at 15:11 UTC | |
by grinder (Bishop) on Dec 17, 2001 at 18:00 UTC | |
by rob_au (Abbot) on Dec 18, 2001 at 03:46 UTC | |
by Anonymous Monk on Dec 18, 2001 at 07:56 UTC |