Advertisement

05.31.2008 at 09:25PM PDT, ID: 23447646
[x]
Attachment Details

Moving & organizing files based on names

Asked by jmohsin in Perl Programming Language

Tags: ActiveState, Perl, Windows XP/ Vista and Perl 5.10

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.txt.  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.txt (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.txt and log the orphans to a file called C:\AppFiles\orphans.txt sorted alphabetically.

Please ask if you have any questions.Start Free Trial
[+][-]05.31.2008 at 09:38PM PDT, ID: 21686049

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05.31.2008 at 09:41PM PDT, ID: 21686055

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.31.2008 at 10:13PM PDT, ID: 21686097

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]06.01.2008 at 09:42PM PDT, ID: 21689613

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]06.01.2008 at 09:46PM PDT, ID: 21689622

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]06.01.2008 at 09:48PM PDT, ID: 21689628

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]06.02.2008 at 12:32AM PDT, ID: 21690156

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]06.02.2008 at 03:38AM PDT, ID: 21690817

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: Perl Programming Language
Tags: ActiveState, Perl, Windows XP/ Vista and Perl 5.10
Sign Up Now!
Solution Provided By: ozo
Participating Experts: 1
Solution Grade: A
 
 
[+][-]06.02.2008 at 12:12PM PDT, ID: 21694687

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628