Adding "keywords" in iTunes

I would like to be able to add multiple keywords to multiple selections of tracks in iTunes. For instance, I would like to select all the tracks that belong to Class A and add the keyword "Class A" to the comments field. Then, I would like to select all the tracks that belong to Class B and add the keyword "Class B" to the comments field.

However, whenever the selections overlap - eg. if a Class B song also belongs to Class A - it overwrites the entire comment. In other words, I would like to be able to ADD a keyword to the comments section rather than simply REPLACE the comments section.

As far as I have been able to determine, this is not possible in iTunes. Whenever you use the Get Info window, and you have multiple songs selected with different info, you can only overwrite a field rather than add to it.

Does anyone know if there is a way to do this? Or have any suggestions on how I might accomplish this task in another way?

Thanks for any help.

Windows Vista

Posted on Aug 4, 2010 3:41 AM

Reply
13 replies

Aug 4, 2010 9:24 AM in response to thaazf

Hi, welcome to Apple Discussions.

When you edit multiple items and they all have exactly the same value for a given field, then that value will be displayed. If different tracks have different values (or if all are blank) then nothing is displayed. So if you want to add a new keyword to a mix of items that have already been assigned keywords then you should select subgroups that already have the same set of keywords and process each subgroup independently.

I use the grouping field for my keywords rather than the comments field and have got used working in the way outlined above, but it seems that this could easily be scripted so that you could select a bunch of tracks, the run the script which would then prompt you for a keyword to add to all the selected tracks (if not already present).

I use / to seprate my keywords. Would this work for you? I can probably knock up a script with options for the field to insert into and the separator to use later this evening.

Thinks.... and -Keyword could be used to remove existing keywords instead of needing a separate script.

tt2

Aug 4, 2010 1:06 PM in response to thaazf

Great, although from the look of things you'll find you need to edit that script each time you want to add in a different keyword and it also bombs out with an error.

You'll find two working scripts at http://samsoft.org.uk/iTunes/scripts.asp

KeywordsToComments & KeywordsToGrouping do the same job for the Comments or Grouping field respectively. Each will prompt you for a keyword (or phrase) to add to the named field, won't duplicate the keyword if already inserted and allows for keywords to be removed by prefixing with a dash.

When I have time I'll try to update it to allow multiple input keywords. In a way it does already, but if you add two keywords separated by slash then you could get duplicates and a proper implementation would allow for easy replacement using *-Keyword 1/Keyword 2*. It might also be nice to add an option to sort the keywords.

I've used / as the keyword separator but you can edit this for any single character including a space if you wish. The script would need further tweaking to allow for a multi-character separator. Using a separator ensures true matches when adding and removing keywords as you won't get a match on a partial substring. The scripts can easily be modified do the same job with any other text field.

tt2

Message was edited by: turingtest2

Aug 4, 2010 2:12 PM in response to turingtest2

Just for fun I've addressed the issue of inserting the file path into comments raised in that earlier link. Use <Location> as a keyword in my scripts and the file location will be added instead. ( -<Location> doesn't remove it yet, but I'll fix that at some point.) The script could easily be modified to support inserting other field values in a similar fashion.

tt2

Aug 8, 2010 3:00 PM in response to turingtest2

Thanks, I've been using your keywords script. I have two questions:

1) Is it possible to get it to operate with selections greater than 500 tracks?
2) Every so often I get an error:

Line: 185
Char: 5
Error: Object required: 'T'
Code: 800A01A8
Source: Microsoft VBScript runtime error

If I start it again with the same selection it will restart, so it`s not a problem with the files it`s working on.

Any ideas?

Thanks.

Aug 8, 2010 5:29 PM in response to thaazf

thaazf wrote:
Thanks, I've been using your keywords script. I have two questions:

1) Is it possible to get it to operate with selections greater than 500 tracks?

Sure, just change the 500 in the line that starts *Const Max=500* for something larger. It just guards against accidentally running it on your entire library, though if that's what you really want to do set the value to 0.
2) Every so often I get an error:

Line: 185
Char: 5
Error: Object required: 'T'
Code: 800A01A8
Source: Microsoft VBScript runtime error

If I start it again with the same selection it will restart, so it`s not a problem with the files it`s working on.

Any ideas?

Does the playlist/selection change at all as the script is run? E.g. is it sorted on comments or grouping? It might just confuse the script if the playlist gets reorganised during that loop. I'll try to see if I can work out how test to prove that the assignment of T has been sucessful. I guess that might still leave some items unprocessed when the script completes, but that should be better than it crashing out.

tt2

Message was edited by: turingtest2

Aug 8, 2010 5:23 PM in response to turingtest2

I was about to say I haven`t been changing the selection while running the script but maybe that`s not true. I set it up to automatically change as it runs.

I`ve been highlighting songs in a smart playlist, with one of the conditions being to exclude songs that include a keyword in the comments. So when the script adds the keyword it removes the song from the playlist. It seemed like a good way to keep on eye on things, but maybe that`s been the problem.

I`ll try it again without doing that.

Aug 8, 2010 5:39 PM in response to thaazf

thaazf wrote:
I was about to say I haven`t been changing the selection while running the script but maybe that`s not true. I set it up to automatically change as it runs.

I`ve been highlighting songs in a smart playlist, with *one of the conditions being to exclude songs that include a keyword in the comments.* So when the script adds the keyword it removes the song from the playlist. It seemed like a good way to keep on eye on things, but maybe that`s been the problem.

Yeah - that would confuse things... I suspect the loop index for the selection goes to pot if iTunes recalculates the contents of the smart playlist.

Changing line 182 to read:
*For I=Count to 1 Step -1*

ought to solve the problem...

tt2

Aug 9, 2010 5:02 AM in response to turingtest2

I've posted updated versions of KeywordsToComments & KeywordsToGrouping.

I've removed the selection limit since there is a prompt warning how many tracks will be processed. The loop order is reversed to avoid the invalid object error. You can now include multiple keywords to add separated by slashes, or prefix a keyword with a dash to remove it. No keyword will be added if it already exists. Keywords will be sorted, though this option can be disabled if you don't want it. As before the keyword <Location> will be dynamically replaced with the file path but now -<Location> can remove it which I'd overlooked before. The current separator is still a slash but this can be changed in the script and multi-character separators will now work properly.

I think I've covered all the bases but I'm open to suggestions if you can think of tweaks to improve it further.

tt2

Aug 9, 2010 7:37 AM in response to turingtest2

P.S. I forgot to mention that the advantage of using Grouping as opposed to Comments for storing your keywords is that you can display all your different groupings in the Column Browser and easily display any selection of them. Plus it leaves Comments free for, um, comments.

Just in case you want to switch your keywords from being in the Comments or the Grouping field I've added <Comment> & <Grouping> as replacement fields so that you can copy existing keywords from one column to the other.

Keywords are processed in reverse order, so to remove all existing keywords from the grouping field and add two new ones you'd use the KeywordsToGrouping script and enter:

Key 1/Key 2/-



tt2

Aug 9, 2010 10:21 AM in response to turingtest2

I was using the Comments field simply because it allowed you to see more characters in the Get Info window.

I don't see how you would be able to "easily display any selection of them" by using the Grouping field?
For example:
Track 1: A / B / C
Track 2: A / C / D
Track 3: A / B / C / D

The column browser wouldn't allow you to select just the B tracks, would it? It would just list them alphabetically by whatever the first keyword happened to be.

I've been using smart playlists with Comment contains/does not contain keywords for sorting. So I guess either Comments or Grouping would work just as well for what I'm doing.

A last question I have: The main search bar can be used to search All, Artists, Album, Composer, and Song. Can that be modified to search just Comments or Grouping? I'm assuming no but it would be very useful if it could.

Thanks very much for all your help.

Aug 9, 2010 11:02 AM in response to thaazf

Using the column browser you can stretch the columns wide enough for most purposes. Either way iTunes limits you to 255 characters for each field. That said the *Get Info* window will probably show more text for Comments than it does for Grouping, but then you need to open & close the window to see it.

Grouping is one of the Columns you can display in the column browser using *View > Column Browser > Groupings*. You can have a max of three columns displayed so you might need to turn off say Genre first. If you're interested in all tracks with the keyword B (a few more letters in your keywords is useful) then type the keyword in the Search box (set to All) which will narrow down the selection to all tracks that have this text somewhere in a text field. The groupings column will now show all the groupings that include B and probably a few random matches. Click on the first correct grouping and then CTRL-click on the remaining correct matches. You now have all the relevant tracks displayed.

You can stil make a smart playlist with the rule Grouping contains B as you have before.

And no, you can't change the options for the Search box.

tt2

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Adding "keywords" in iTunes

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.