How to create subfolder for 5 files at a time

Bulk Rename Utility How-To's

How to create subfolder for 5 files at a time

Postby cjonesmn » Tue Nov 12, 2019 6:11 pm

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!
cjonesmn
 
Posts: 4
Joined: Tue Nov 12, 2019 6:03 pm

Re: Create folder for 5 files at a time

Postby Admin » Wed Nov 13, 2019 12:11 am

How are the 5 files grouped together in a folder, according to which criteria?
Admin
Site Admin
 
Posts: 2344
Joined: Tue Mar 08, 2005 8:39 pm

Re: Create folder for 5 files at a time

Postby cjonesmn » Wed Nov 13, 2019 1:00 am

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.
cjonesmn
 
Posts: 4
Joined: Tue Nov 12, 2019 6:03 pm

Re: Create folder for 5 files at a time

Postby Admin » Wed Nov 13, 2019 2:16 am

Hi, it can be done with Javascript renaming if you have a commercial license we can post script here. thanks
Admin
Site Admin
 
Posts: 2344
Joined: Tue Mar 08, 2005 8:39 pm

Re: Create folder for 5 files at a time

Postby Admin » Fri Nov 15, 2019 1:20 am

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.
Admin
Site Admin
 
Posts: 2344
Joined: Tue Mar 08, 2005 8:39 pm

Re: Create folder for 5 files at a time

Postby cjonesmn » Fri Nov 15, 2019 10:28 pm

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).
cjonesmn
 
Posts: 4
Joined: Tue Nov 12, 2019 6:03 pm

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

Postby Admin » Sat Nov 16, 2019 12:04 am

newName = "2" + newName;


added as the last line, should do it.
Admin
Site Admin
 
Posts: 2344
Joined: Tue Mar 08, 2005 8:39 pm

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

Postby cjonesmn » Sat Nov 16, 2019 12:45 am

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!
cjonesmn
 
Posts: 4
Joined: Tue Nov 12, 2019 6:03 pm


Return to How-To


cron