Simple Genre filtering in a iTunes music folder

Started by keepsound, October 16, 2017, 03:37:41 PM

Previous topic - Next topic

keepsound

Hi, my first post here.
Sorry for my inexperience, I've found this app just fews days ago.
Now I'm searching to filter out the songs in a folder/playlist as genre.
I've tryed some scripts in Terminal (OSX) but get inconsistence results.
The script is
exiftool -Genre -17 [Dir path] (-17 should be Rock)
Tryed always with other tags, like -TCN (2_2) or -TCON (2_3) but with the same result...
Whats happened is this: with any Genre ID I get the same full list of the Folder/Directory, with exception of ID tags <=-11 (Tags not recognized or somewhat similar)
Any help? Thanx in advance.
Italo

StarGeek

If you want to look for files where the Genre tag is equal to "Rock" (this is case sensitive), then your command would be
exiftool -if '$Genre eq "Rock" ' DIR

Normally, exiftool with translate the raw Genre data into a human readable form.  If you want to search by the raw data, then you would use
exiftool -if '$Genre# == 17 ' DIR

In this case, adding the hashtag after the tag name accesses the raw data.  Since this is now a numeric rather than string comparison, == is used instead of eq.
* Did you read FAQ #3 and use the command listed there?
* Please use the Code button for exiftool code/output.
 
* Please include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).

keepsound

Hi, many thanks for your quick answer. But something is not working with the second example (now I'll try the first one).

keepsound

Same, not working too (see attached screenshot)

StarGeek

Minor mistake on my part, I forgot to add -Genre to my commands so as to only print the Genre tag, but that didn't matter because all 7 files failed.

Mistake in your second screen shot, where you used both eq (string comparison) and == (numeric comparison).  That should have just been eq.

But none of that explains why the command didn't show something.

Try this command:
exiftool -g1 -a -s -genre DIR

Instead of attaching a screen shot, copy the output to the clipboard and paste it here in the forum.  Then select what you just pasted and press the code button above the text box.  It's much easier to read and check for errors than a screen shot.
* Did you read FAQ #3 and use the command listed there?
* Please use the Code button for exiftool code/output.
 
* Please include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).

StarGeek

Upon further testing, I think I figured out what was wrong.  ID3v2_3:Genre (maybe also ID3v2_4? not sure) doesn't return a raw number, it only returns the text for Genre.  This also has priority over ID3v1:Genre, which does have a raw number. 

So
exiftool -if '$Genre# == 17 ' -Genre DIR
won't work if there are newer version tags.  Though you could try
exiftool -if '$ID3v1:Genre# == 17 ' -Genre DIR
if you are certain there are ID3v1 tags.

You're better off sticking to the text version, IMO. 
exiftool -if '$Genre eq "Rock" ' -Genre DIR
* Did you read FAQ #3 and use the command listed there?
* Please use the Code button for exiftool code/output.
 
* Please include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).

keepsound

Hi StarGeek
yesssss, the last solution is working fine!
many many many many thanks!!!
Now I've implemented the script in MaxMSP, using shell, and this works well too, also if the obj doesn't recognize the command exiftool directly (I've used a workaround see screenshot A)

The id3 Tags in the folder used for test (Last CD of David Bowie, AIFF grabbed files see screenshot B) is ID3v2_2, but this can be various because the real folder used for filtering can contain many files of any kind (also more than 1000 files).

And the next filtering should be to extract any file as Genre, comprising in years periods, like find any blues song from year 1960 to 1980, or rock song from year 1950 to 2000... will see if now I can do that from myself, using your great hints!

Best regards
Italo

keepsound

Hi,
now I've tryed to transform the script to get the songs of a year, and it works fine for AIFF files, but it doesn't work for m4a files. What I've done wrong?
Here my script:

exiftool -if '$Year# == '2014' ' -Year '/Users/italolombardo/Music/iTunes/iTunes Media/Music/U2/Songs of Innocence/'

this script works also with other conditionals like >= or <=, but only for folders containing AIFF files.
And other thing, the script works fine for the Genre tag, also if the DIR is populated with m4a files... (but not for the Year tag...)

Another question is, how can I combine this 3 scripts in only one? I mean Genre, plus <= Year and plus >= Year ?
Thanks in advance for my last question here.
Italo

Phil Harvey

Your quoting is odd.  Try -if '$year# == 2014'  (no extra quotes around 2014)

- 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 ($).

StarGeek

Find an m4a file that doesn't get read and make sure it has a Year tag with
exiftool -g1 -a -s -Year File.m4a

To combine it all, you can use AND
exiftool -if '$Year>=1977 and $Year<=1999 and $Genre="Rock" ' -Year -Genre FileOrDir

Plain numbers shouldn't need quotes.  Since you're on Mac/Linux, you use single quotes to group bits (like the full argument to -if) and double quotes around strings that are inside the group ("Rock").  On Windows this is the opposite in case you see a command elsewhere on the board you want to try out.
* Did you read FAQ #3 and use the command listed there?
* Please use the Code button for exiftool code/output.
 
* Please include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).

keepsound

Hi, many thanks again. Everything is working fine. I've only tryed to add the genre and year ID3 to an empty file, but without success. Will do it in itunes.
Here's the screenshot of the app done in MaxMsp (there are 18 filtering, everyone goes to a single playlist. Now this is only a example and the tags are all the same, but it works fine. The years column is updating automatically, and the genre column is copied from the common tags)
Best regards
Italo