Move x amount of files into incremental folders

Advanced Renamer forum
#1 : 30/01-21 23:53
Ricky Boston
Posts: 1
Hello, I'm new to this program.
I am searching for a program to move files from one folder to subfolders, but with a maximum amount of files per folder.

example:
I have a folder named "various". Inside this folder I have 788 files total.
I would like to batch move all the files inside the "various" folder into subfolders with a limit of 200 files per folder. The name of the subfolders must be automatically created in increments of the parent folder name "various" + 001, eg. various001, various002, etc.

The end result should look something like this:
Various/various001/{filename1}
Various/various001/{filename2}
...
Various/various001/{filename200}

Various/various002/{filename1}
Various/various002/{filename2}
...
Various/various002/{filename200}
etc.

If the folder name "various" can't be appended to the subfolders, I'm ok with only the numbering for the subfolders, e.g. 001, 002, 003, etc..

Is this possible with the Advanced Rename application? I tried the Move files batch mode, but could only get it to put all the files in it's own subfolder. Meaning, with 788 files, I also get 788 subfolders.

Thanks in advance for any help with this.

#2 : 31/01-21 10:59
David Lee
Posts: 1125
Use a Script method with the following code:

N=200;
dir = app.parseTags("<DirName>");
item.newPath=item.path + dir + ("00" + (Math.floor(index/N) + 1)).slice(-3) ;


For an introduction to the Script method check out the User Guide:

www.advancedrenamer.com/user_guide/method_script
www.advancedrenamer.com/user_guide/example_scripting

For a more detailed introduction to JavaScript a good resource is: www.w3schools.com/js

edited: 31/01-21 11:35