Seeking help to create new keyword to group files in 250 files per group

Started by E_Rap, March 03, 2023, 08:37:49 PM

Previous topic - Next topic

E_Rap

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.

Phil Harvey

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
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).