Page 1 of 1

Files iTunes automatically adds to the Music folder?

PostPosted: Tue Jul 26, 2011 5:11 pm
by gvmelbrty
I'm trying to get Hazel to add a Spotlight comment to music files that have been automatically added to the iTunes Music folder. iTunes is set to manage the media folder. A rule is in Hazel to watch the iTunes "Music" folder and add a Spotlight comment to the music files. But, nothing happens when music files are dropped onto iTunes (or CDs are ripped by or music is purchased in iTunes). … I assume this has something to do with iTunes not telling the Finder that anything has happened to the Music folder when it adds music to it.

Any ideas?

The reason I'm trying to add a Spotlight comment to the music files is there are multiple users on my Mac, but we all share one iTunes Media folder location (you can specify a central location in iTunes prefs under "iTunes Media folder location"). What I'm trying to do is create a way to notify users when other users add music to the computer.

When each user adds music to iTunes, the music files themselves are added to the central location (in this case on an external HD) because iTunes is set to "copy files to iTunes when added to library." BUT, the music entry only shows up in the iTunes window for the user that added it (that's just how it works). All other users must first know that new music is available, and then manually drag the music files from the central location onto their iTunes window for it to show up in their iTunes.

So, if I can tag the music files as they are added with the user's name, then I can create smart folders for each user that search the music folder for files that DON'T have their name, meaning it's new music to them. Then they can look inside the smart folder and see that new music is available and decide if they want to add it or not. Then, using a simple Automator action, that user can add their name to the Spotlight comments for those music files, signifying that they have reviewed the new music, causing their smart folder to be empty.

Re: Files iTunes automatically adds to the Music folder?

PostPosted: Wed Jul 27, 2011 3:02 pm
by Mr_Noodle
I'm guessing the problem is that music files aren't actually deposited at the top level, but instead are filed in subfolders based on artist and album. In such a case, you need to have Hazel descend into subfolders. You can read more on it here: viewtopic.php?f=4&t=470

That said, it can be very resource intensive. A better solution may be to set up a folder where you drop music into. It sets the comment then imports into iTunes itself. That way, you don't have to do a search through your whole music library every time.

Re: Files iTunes automatically adds to the Music folder?

PostPosted: Thu Jul 28, 2011 3:29 pm
by gvmelbrty
Thanks for the suggestions.

I tried setting up a separate drop folder where the Spotlight comment is set, then the file is imported into iTunes (although this doesn't deal w/ files ripped by or purchased through iTunes). But once the files arrive in the iTunes Music folder, the Spotlight comment is stripped out.

Folder: iTunes import test
- Rule #1:
If all of the following conditions are met: Any File
Do the following:
Add comment: tom (uncheck Replace existing comment)
Import into iTunes to playlist Library

Files placed into the drop folder do have the correct comments, but they are missing from the same file imported into the iTunes Music folder. I have no idea why this is happening, but I know it has nothing to do with Hazel. I added a Spotlight comment to a music file and then dropped it onto iTunes. The comment was stripped out in this case as well.

Next, I tried the "run rules on folder contents."

Folder: iTunes Music folder
- Rule #1:
If any of the following conditions are met: Kind is Folder
Do the following:
Run rules on folder contents
- Rule #2:
Kind is Music
Date Added is in the last 5 minutes
Do the following:
Add comment: tom (uncheck Replace existing comment)

This works when adding new artists and iTunes creates new artist and album folders. But if subsequent albums (or individual songs from existing albums) are added to an existing artist, then the comment is not added (iTunes creates a new album folder, but NOT a new artist folder).

I assume this is because since the watch folder is the iTunes Music folder, Hazel only runs rules when it sees something happening at the top level of this folder. If something new is added to a folder that already exists, then Hazel doesn't see it. The only way I see around this is to run the Hazel rule manually.

Thanks, Tom

Re: Files iTunes automatically adds to the Music folder?

PostPosted: Fri Jul 29, 2011 2:51 pm
by Mr_Noodle
I'm guessing iTunes doesn't copy comments when copying files in.

As far as your second set of rules, you should not do "date added is not in the last 5 minutes". If Hazel gets to the file late, it won't get processed. I'd suggest doing "Date added is after date last matched" which means it was added since the last time the rules were executed.