counting files in zip / help in regEx

Advanced Renamer forum
#1 : 22/11-22 12:12
mike
mike
Posts: 19
hi,

1/ there was a trick of how to count files packed in the .zip file, but can't find this thread.
Maybe someone can help.

2/ i have the 2 file's name types:

a) <date> px<num>
b) <date>

i want to add px<num> sequence after <date> only when there is no such sequence already, so only in files of type b)

can it be done with one sequence - was trying to play with lookahead bo no success :(
(some explanation would be very welcome) :-)

tia
mike


22/11-22 12:12
#2 : 22/11-22 14:06
David Lee
David Lee
Posts: 1026
1/
The tag <ExifTool:Warning> returns a string in the format:
"[minor] Use the Duplicates option to extract tags for all <nn> files"
where <nn> is the number of files in the zip archive.

You can use this in a script to extract the number of files with:
noFiles = app.parseTags("<ExifTool:Warning>").match(/\d+/);

2/
Use a Script method...

In the pre-batch script determine the largest existing px number:

count = 0;
for (j=0; j<app.itemCount; j++){
n = app.getItem(j).name.match(/px(\d+)/);
if (n) count = Math.max(count, n[1]);
}

Then, in the main script, add an incrementing subscript if it is not already present:

name= item.name;
n = name.search(/px\d+$/);
if (n==-1) return name + "px" + ++count;


22/11-22 14:06
#3 : 22/11-22 14:55
mike
mike
Posts: 19
Reply to #2:

David, thanks a lot, will play with it.


22/11-22 14:55