I need a Perl script to do the following...
1. I have a collection of about 100000 files located in a windows directory called C:\AppFiles.
2. I would like to organize these 100000+ files under a series of 50 or so directories located in C:\AppFiles.
3. The CASE-SENSITIVE names of these 50+ directories are contained in a file called C:\AppFiles\SubDirNames.tx
t. Each line in this file has the name of one sub-directory that may exist under C:\AppFiles. Let us say that the lines in the SubDirNames.txt file are SubDir1, SubDir2, SubDir3, and so on and so forth.
4. The file names under each subdiretory SubDirN, where N ranges from 1 thru 50+, follow a simple convention. The LARGEST files is named SubDirN_00001, the second largest files is named SubDirN_00002 and so on and so forth...
5. Here is the algorithm to organize the files:
a. Loop through EACH SubDirN in file C:\AppFiles\SubDirNames.tx
t (remember: each line in the SubDirNames.txt has the name of ONE subdirectory)
b. Do a case-insensitive search in C:\AppFiles for files that contain the string SubDirN in their name.
c. If you find any matches, they need to be moved to C:\AppFiles\SubDirN subject to criteria outlined in requirement #4 above. Please note the SubDirN may or may not exist.... You will need to check for this EVERY time the script is run.
d. Leave the "orphans", i.e. files in C:\AppFiles that do not match any of the SubDirN entries in C:\AppFiles\SubDirNames.tx
t and log the orphans to a file called C:\AppFiles\orphans.txt sorted alphabetically.
Please ask if you have any questions.
Start Free Trial