Hello all,
I'm trying to lc all files and subdirectorys w/n a path. This so far
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++;
}
Output:
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"
Notes:
- Maybe the "opendir" has something to do w/why perl won't
see the directory's in "-d $fname" (tried diff things :) )
- Also the renaming feature is jacked up..
Plus i want to rename the current and every dir/file w/n...
It's better than renaming all 3200 files...
Enjoy
Edited by japhy -- please reserve <code>...</code> tags for actual code
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.