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
Smart folder
Moderators: JRL, Dorian (MJT support)
- Bob Hansen
- Automation Wizard
- Posts: 2475
- Joined: Tue Sep 24, 2002 3:47 am
- Location: Salem, New Hampshire, US
- Contact:
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!
Bob
A humble man and PROUD of it!
- Bob Hansen
- Automation Wizard
- Posts: 2475
- Joined: Tue Sep 24, 2002 3:47 am
- Location: Salem, New Hampshire, US
- Contact:
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.
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!
Bob
A humble man and PROUD of it!