Rename the folder using the file contents

Advanced Renamer forum
#1 : 08/08-22 13:58
JiMu
JiMu
Posts: 2
Rename the folder,
The folder contains 72 images and 5 videos,
I want the folder name to be 72+5.


08/08-22 13:58
#2 : 08/08-22 17:00
David Lee
David Lee
Posts: 989
I don't think that this is possible directly.

However a workaround is to use a Script method, working on one folder at a time....

Load all the files in the folder into the list and select "Add the files in the folders"

Select Batch mode: Rename

Add a Script method

In the Pre batch script count the number of image and video files in the list and create a new path for the files.

Then in the main script simply set newPath for each file to the value created in the Pre batch script - you don't need a Return statement because you are not renaming any files.

For example: assuming you have files of type .avi, .mov, .jpg, .png & .gif...

In the Pre batch script:

images = 0;
videos = 0;
for (n = 0; n < app.itemCount; n++) {
file = app.getItem(n);
ext = file.ext;
if (ext == '.avi' || ext == '.mov') videos++;
if (ext == '.jpg' || ext == '.png' || ext == '.gif') images++;
}
newPath = file.path.match(/(.*\\).*\\$/)[1] + images + '+' + videos;

... and in the main script:

item.newPath = newPath;

When you run the batch; all the image and video files will be moved into a new folder, named as you have requested, in the same root directory as the original folder. The original folder will have to be deleted manually.

Just edit the "if" statements as approtriate for the filetypes you have.


08/08-22 17:00