ExifTool Forum

ExifTool => Newbies => Topic started by: E_Rap on March 03, 2023, 08:37:49 PM

Title: Seeking help to create new keyword to group files in 250 files per group
Post by: E_Rap on March 03, 2023, 08:37:49 PM
I know ExifTool can recursively process files (-r) but I need help as I am trying to create a keyword to group 8,000 files into groups of 250.  I would like the keyword to be something like Group_***_nnn where *** is a three letter combination like AAA and nnn is a three number combination 001.

I do not want to change the file name I just want to add a new keyword to an .mp3 file that marks my files into groups of 250.
Title: Re: Seeking help to create new keyword to group files in 250 files per group
Post by: Phil Harvey on March 03, 2023, 09:15:19 PM
So you want the keywords to be Group_AAA_001, Group_AAA_002 ... Group_AAA_250, Group AAB_001, AAB_002 ... ?

Assuming this to be the case, and also assuming you want to write the keyword to XMP:Subject.  And further assuming you want to preserve existing keywords.  And also assuming you want to number the keywords in the same order as the file names sorted alphabetically, the command could be:

exiftool -fileorder filename "-subject+<${filename;$a or $a=q(AAA);$b = 1 if not $b or (++$b > 250 and ++$a);$_=sprintf(q(Group_%s_%.3d),$a,$b)}" DIR

- Phil