counting files in zip / help in regEx
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
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
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;
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;
Reply to #2:
David, thanks a lot, will play with it.
David, thanks a lot, will play with it.