Page 1 of 1

How to create subfolder for 5 files at a time

PostPosted: Tue Nov 12, 2019 6:11 pm
by cjonesmn
I work with HDR photography. What I want to do is take all files in a folder (of images) and create a separate folder for every set of 5 files (images). Is there a way to do this in the Bulk Rename Utility?
Thanks!

Re: Create folder for 5 files at a time

PostPosted: Wed Nov 13, 2019 12:11 am
by Admin
How are the 5 files grouped together in a folder, according to which criteria?

Re: Create folder for 5 files at a time

PostPosted: Wed Nov 13, 2019 1:00 am
by cjonesmn
All the brackets are located in one folder ("master"), sorted by filename (in sequence). Ideally I'd like to copy the first 5 photos in the master folder to a folder titled "001". After those files are copied, the script would then grab the next 5 photos (6-10) and move those to a new folder titled "002". This would continue until all files have been copied from the master folder to the new folders.

Re: Create folder for 5 files at a time

PostPosted: Wed Nov 13, 2019 2:16 am
by Admin
Hi, it can be done with Javascript renaming if you have a commercial license we can post script here. thanks

Re: Create folder for 5 files at a time

PostPosted: Fri Nov 15, 2019 1:20 am
by Admin
Hi, here is the Bulk Rename Utility javascript needed to group files into subfolders:

Code: Select all
function padLeft(nr, n, str){
    return Array(n-String(nr).length+1).join(str||'0')+nr;
}

var groupevery = 5;
var pad = 3;

var num = ((counter+groupevery-1) / groupevery) >> 0;
newName = padLeft(num,pad) + '\\' + name;


The option Allow Using '\' in Renaming Criteria for Creation of New Folders needs to be enabled in the renaming menu.
The var groupevery sets the number of files to group in each subfolder.
The var pad sets how many 0 to pad the subfolder name with.

Re: Create folder for 5 files at a time

PostPosted: Fri Nov 15, 2019 10:28 pm
by cjonesmn
Admin wrote:The option Allow Using '\' in Renaming Criteria for Creation of New Folders needs to be enabled in the renaming menu.
The var groupevery sets the number of files to group in each subfolder.
The var pad sets how many 0 to pad the subfolder name with.

Okay, perfect! Now what would I do if I wanted to create folders that were titled "2001", "2002", etc instead of "001", "002". (My javascript knowledge is very old).

Re: How to create subfolder for 5 files at a time

PostPosted: Sat Nov 16, 2019 12:04 am
by Admin
newName = "2" + newName;


added as the last line, should do it.

Re: How to create subfolder for 5 files at a time

PostPosted: Sat Nov 16, 2019 12:45 am
by cjonesmn
Admin wrote:
newName = "2" + newName;


added as the last line, should do it.

Thank you, you are going to save me countless hours. I appreciate it very much!