Hi-
I’ve scoured for how to pull this one off, but no one has it exactly how I want to do it; that is how I ended up here on this BBS.
I currently store all of my iTunes songs on an external hard drive using the option in iTunes 7.0.2 (15) called “iTunes Music Folder location” located under the “Advanced” → “General” tab. The mounted location is called “IOMEGA:ITunes”.
What I want to do is have reliable way of completely deleting a song from inside of iTunes. What I mean by this is:
- If I hit shift+delete on a highlighted song, I want the song to delete from the iTunes playlist
- delete from the remote folder on the remote drive, “IOMEGA:ITunes”
- if possible - also delete whether the file is in a playlist or not.
I have way too much music right now and need an expedient way to delete massive quantities without having to go into the folder sub-structure and find the songs. Most things aren’t even named properly, so finding these things is a total waste of time. What I need is something that complete destroys these songs down to the file structure.
Please help me here. I have a decent knowledge of programming from C++ to VB.net to Java but have little to no familiarity with AppleScript. Every solution I have found so far on the net either doesn’t work properly with this itunes version or cant account for the fact that the library I have is in a remote location on a remote harddrive.
Best Wishes,
David Brown
Hi, David.
I don’t use iTunes very much, but it seems to be the case “ after a morning’s poking around “ that only one track is created in the Library’s “Music” folder for any particular file and that deleting this track also deletes any track depending on the same file in any of the user playlists.
The script below identifies the file of each ‘file track’ in an iTunes selection and deletes the associated track from the Library. When it’s deleted all the relevant tracks, it then deletes the files themselves. Hope it does what you want.
tell application "iTunes"
-- Get a list of the Library file tracks and another of their locations (file aliases).
set libraryFileTracks to file tracks of library playlist 1
set libraryLocations to location of file tracks of library playlist 1
-- Get a list of the selected tracks.
set theSelection to selection
-- Initialise a list for the files of the selected tracks.
set theFiles to {}
-- Loop through the items in the selection.
repeat with thisTrack in theSelection
if (thisTrack's class is file track) then
-- If this selected item's a 'file track' (it probably is), get its file.
set thisLocation to thisTrack's location
-- If the file exists, add it to the list of found files.
if (thisLocation is not missing value) then set end of theFiles to thisLocation
-- Find the matching alias in the list of Library locations and delete the associated
-- Library track. This should also delete instances of the track in other playlists.
repeat with j from 1 to (count libraryLocations)
if (item j of libraryLocations is thisLocation) then
delete item j of libraryFileTracks
exit repeat
end if
end repeat
end if
end repeat
end tell
-- Delete the no-longer-needed files.
tell application "Finder" to delete theFiles
By the way, the “Mac OS” forum is rather misleadingly named. It’s actually intended for for matters associated with versions of Mac OS before Mac OS X. The “OS X” forum would be more suitable for “iTunes” questions.
Not to be a bum steer - but this script you sent me does not work at all. I see in your last post you suggested I switch forums with this post. I guess I’ll do that but wanted to ask your opinion why this isn’t working?
I think you may have misunderstood what i want to do.
If i am in Library → Music and the blue cursor is over a song.
I want to run this script. Delete the song from itunes and have the song simultaneously deleted from my remote hard drive so that the songs binary / file structure end up in the trashcan which I can later empty.
David Brown
Hello, David.
That’s exactly what it does here. To test it, I copied my iTunes folder to an external disk attached to my other machine and set the iTunes preferences on this machine to use that copy. The script deleted all selected tracks from the Library and from any playlists “ whether they were selected in the Library or the playlists “ and deleted the appropriate files from the remote iTunes folder. The files didn’t go to the trash because files deleted remotely over the network are zapped in situ. The script won’t respond to shift-delete unless you have some software that arranges for it to do so and it may need to be saved as an application for this. It’s slightly possible there may be some horrendous difference between my iTunes 7.0 and your 7.0.2, but I wouldn’t have thought so.