Smart folder

Technical support and scripting issues

Moderators: JRL, Dorian (MJT support)

Post Reply
timle
Pro Scripter
Posts: 96
Joined: Tue Apr 20, 2004 5:53 am

Smart folder

Post by timle » Fri Jan 30, 2009 12:26 am

Could any one show me how to distribute files from one folder to 3 folders evenly.
I have one INfolder and the script would look at it to see any file, it would move to OUTfolder1, if it see another file, it will copy it to Outfolder2, and the next file will be moved to OUTfolder3

Thank you

User avatar
Bob Hansen
Automation Wizard
Posts: 2475
Joined: Tue Sep 24, 2002 3:47 am
Location: Salem, New Hampshire, US
Contact:

Post by Bob Hansen » Fri Jan 30, 2009 4:24 am

Here is a quick, untested approach:
===================================

Code: Select all

// Use GetFileList, Separate the files, and get the count of files.
// Add a Loop counter to "folder" to get the destination folder name.

GetFileList>c:\temp\*.*,files
Separate>files,;,filenames
// This will also give you a count of the files, %filenames_count%

// Now loop using copy file to folders
vCount=0
Label>Loop
vCount=%vCount%+1
CopyFile>filename_%vCount%,folder%vCount%
If>vCount=%filenames_count%,End,Loop

Label>End
Hope this was helpful..................good luck,
Bob
A humble man and PROUD of it!

timle
Pro Scripter
Posts: 96
Joined: Tue Apr 20, 2004 5:53 am

Post by timle » Fri Jan 30, 2009 4:04 pm

This will work, but if I just drop one file at a time in the Input folder, then the script will only see one file at the time and put the files in Output folder1 all the time ?

User avatar
Bob Hansen
Automation Wizard
Posts: 2475
Joined: Tue Sep 24, 2002 3:47 am
Location: Salem, New Hampshire, US
Contact:

Post by Bob Hansen » Fri Jan 30, 2009 6:59 pm

Yes.

It is set up to handle any number of files (but it does not create new folders or check for them. It assumes you have folders named folder1 - foldern. Would not take too much to create that.

But, are you looking to just add files to three folders and keep an equal amount in each? So you just add files to a source folder, then move them to folders 1,2,3,1,2,3,1,2,3,etc.?
In that case, suggest making an INI file that stores the last folder used, or the next one to be used, and modifying the loop to read the INI file, and cycle around using 1 through 3 vs. incrementing to file count. Modify the loop to change the INI file with each Move.
Hope this was helpful..................good luck,
Bob
A humble man and PROUD of it!

timle
Pro Scripter
Posts: 96
Joined: Tue Apr 20, 2004 5:53 am

Post by timle » Fri Jan 30, 2009 7:13 pm

Yes that's exactly what I wanted to do , I want to distribute files evenly in 3 folders

thanks

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts