Delete iTunes library entry on deletion of file?

Get help. Get answers. Let others lend you a hand.

Moderator: Mr_Noodle

Hi -

I must be missing something; how do I cause Hazel to *remove* an entry from iTunes library when I delete a file?

(This is a useful thing to have, since deleting an iTunes library entry within iTunes no longer provides the ability to delete the file itself. So, having the ability to simply delete the file, and have iTunes updated, is a desired ability.)
batsonjay
 
Posts: 6
Joined: Mon Dec 03, 2018 1:16 pm

I believe iTunes should delete the original. I know when I delete files in iTunes, it brings up an alert with the option to throw it in the trash.
Mr_Noodle
Site Admin
 
Posts: 8697
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

Mr_Noodle wrote:I believe iTunes should delete the original. I know when I delete files in iTunes, it brings up an alert with the option to throw it in the trash.


This is because you have iTunes set to manage your files (e.g. you have the option "Keep iTunes Media folder organized" and "Copy files to iTunes Media folder when adding to library" are both checked.)

If a user does NOT use iTunes to manage the library, iTunes will not offer to delete the file. Many users must choose this option when their audio library grows large, and it becomes necessary to store media on an external storage device. In this case, deleting a song in iTunes deletes the library entry in that instance of iTunes, and also deletes it on all devices to which that library syncs, but does not offer to delete the file.

Thus, having the ability to delete an iTunes entry on deletion of a file in a watched folder is highly valuable to those users.

In fact, I can make a case that "in general", providing a mechanism for a rule to fire on file deletion is a valuable function. Consider these use cases:
  • A user may wish to know if a valid, or malicious application attempts to remove a file from a critically-watched folder, and thus set up a notification when a file is deleted from that folder.
  • Tracking deletion date. A user may wish to add a comment containing a date/time stamp to a file that is moved to the trash; this may be a useful item of info if a user wishes to restore a deleted file in the case there are several files with the same name.
  • (The captioned use case for iTunes)
  • (Similar use case for iPhoto)

I acknowledge this complicates the UI a bit, since the entire rule panel makes a presumption about when a rule will be evaluated.

I suggest a phased approach: Handle the iTunes (and maybe iPhoto) use case first, then consider if a larger capability is required.

An iTunes/iPhoto-only feature could be provided by an easter-egg type hack:
- IF the user sets "Kind" is "Music" in the conditions area;
- THEN
1) Add an entry to the file attribute selector in the conditions section (e.g. the one that has "Passes AppleScript"), adding an entry "Removed from folder", with secondary attributes of (only) "Is" and "True"
-- This allows the user to set a second condition "Removed from Folder"; this provides a 2-rule match that will fire when "Kind is Music" and "Removed from folder is true". There is an error condition that must be checked: This rule only makes sense when "All" of the conditions are met. I'll leave it to you to figure out how to handle that.
-- Yes, I realize this makes the attribute selector contents different depending on context; like I said, this is an Easter Egg ;-D)
2) Add an action "Remove from iTunes" (from playlist ("Library", ....)).

Yes, it's a hack; but it's a useful hack, hopefully won't break anything, and is reasonably aligned with the overall UI metaphors.
batsonjay
 
Posts: 6
Joined: Mon Dec 03, 2018 1:16 pm

Having rules matching files on removal opens up a whole other slew of issues. It's something I've thought about off and on but there's a bit that needs to be worked out.

Going back a bit, you can have your library on a separate drive and have iTunes still manage it. In iTunes' Advanced preferences, you can set the location of your library, which can be on another drive.
Mr_Noodle
Site Admin
 
Posts: 8697
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

Mr_Noodle wrote:Having rules matching files on removal opens up a whole other slew of issues. It's something I've thought about off and on but there's a bit that needs to be worked out.


I hope you will. I've continued to think about this, and continue to wish I could set rules to fire when a file is deleted.

Mr_Noodle wrote:Going back a bit, you can have your library on a separate drive and have iTunes still manage it. In iTunes' Advanced preferences, you can set the location of your library, which can be on another drive.


This is true. However, there are other reasons to not have iTunes manage files. I'm a working DJ, and having iTunes try to out-think me when I'm constantly previewing, organizing, sorting tracks is a major pain. I will decide what I want in iTunes, when, and I don't want iTunes constantly trying to manage my life, though I do want to intentionally put things in iTunes sometimes, because other DJ apps rely on the iTunes database.

The lack of deletion rule support caused me some unintended side effects today. I realized that I had not created a rule to pull a particular folder of music into iTunes. I did so, but just after I created the rule & it started running, I remembered there was a reason I hadn't created the rule: I have a ton of music in that folder I do NOT want in iTunes (because I simply hadn't yet deleted it). Now I've got to go thru a few hundred tracks in iTunes & manually delete them there, TOO, as I delete them from my drive.

I continue to want a the little hack I proposed above, which avoids most of the general case problems.
batsonjay
 
Posts: 6
Joined: Mon Dec 03, 2018 1:16 pm

Bump.

As you are thinking about the switch from Pref Pane to Application for Hazel 5, is it possible for you to incorporate the discussion here (having Hazel fire on deletion of a file?

This would still be very useful to me (and I suspect others).

I acknowledge you likely have a lot to do during creation of Hazel 5; but maybe by reminding you now of this potential need, you can think of a way to add it as you re-work the UX for 5.
batsonjay
 
Posts: 6
Joined: Mon Dec 03, 2018 1:16 pm

That is totally independent of re-working the UI. It's still under consideration but if anything, re-doing the UI takes away time from doing other things such as this.
Mr_Noodle
Site Admin
 
Posts: 8697
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City


Return to Support