#1 : 21/06-24 16:12 Arthur
Posts: 4
|
Hello!
I have a task to copy a large number of files and upload them to a website. However, there is a challenge. I need to upload files in batches of 600, 1000, or N at a time. Therefore, if I have a list of files, I need to be able to copy them into folders like "G:\Images for Uploading\[sequence number of the folder]" and adjust the N as needed. Can you help me out with this thing please? |
#2 : 21/06-24 17:55 Delta Foxtrot
Posts: 285
|
Reply to #1:
Hi Arthur, I don't know how to copy files the way you want, but this script will move them to folders of ascending numbers that contain whatever number of files you tell it. Just be sure your files are backed up before you pull the trigger (in other words, it worked for me on a couple hundred files but no guarantees it will work on thousands or on your situation EDIT: although I'm pretty sure it will END EDIT). Adjust the first two values in the pre-batch script for what you want. The variable "n" is the number of files for each directory. The script will always use the directory the files started in as the root dire/ctory for whatever you put in the "baseFolder" variable. (Keep the double-backslash, by the way). PRE-BATCH SCRIPT: // folder for moving files to: const baseFolder = "\\images for uploading\\" ; // number of files for each subfolder: const n = 20 ; // file number counter: const fileNr = 0 ; // folder number counter: const folderNr = 1 ; -------------------------------------------------------- SCRIPT: if (fileNr >= n) { // we are above range of current output folder; // We have to increment to new folder and reset file counter fileNr = 0 ; ++folderNr ; } // Create new path string: item.newPath = item.path + baseFolder + folderNr.toString() ; ++ fileNr ; -------------------------------------------------------- (No return statement needed) Best, DF |