Calling perl gurus,
Hello, help please!!! Looking to delete empty directories, I have a script
for that but if the directories have files in them, it dies. Either can I
add some type of script to delete them also or can I just avoid them all
together and just delete the empty ones. Any help would be much
appreciated. Thank you.
P.S. All directories are capital letters, that's how I call them. All
lowercase needs to stay in directory. Thanks again.
Chris
#!/opt/perl5/bin/perl -w
# This script is used to remove capital letters from xxx/xxxx/b2222
# /xxxxx/spec directory
chdir "/xxx/xxxxx/xxxxx/xxxxx/spec" or die $!;
# chdir "/u131/tmp" or die $!;
opendir(HERE, '.');
@AllFiles = readdir(HERE);
foreach $Name (@AllFiles) {
if (-f $Name) {next}
if ((-d $Name) and ($Name =~ /^[A-Z]+$/)) {rmdir $Name or die $!};
if ((-d $Name)) {print "$Name\n"}
}{ die "All done. Thank You!\n" }
}
"rmdir.perl" 24 lines, 495 characters