Delete the Currently Playing Song!

GO TO ADMIN PANEL > ADD-ONS AND INSTALL VERTIFORO SIDEBAR TO SEE FORUMS AND SIDEBAR

Tedg

New member
Joined
Jul 22, 2003
Messages
5
Points
0
Location
Virginia Beach
Website
www.sirius-beta.com
This may be a simple script, which I hope helps me learn.

Like many folks, I download a lot and I really don't know if I like something until I hear it. If I do not, I want it gone right then and there, removed from the library and trashed. Even (especially if) iTunes is in the background.

Anyone know how to do it?

Best, Ted
 

deeg

New member
Joined
Jul 1, 2003
Messages
394
Points
0
Location
Swampland, UK
hi ted,

try the following...

Tell application "iTunes"
copy (get location of current track) to theLocation
ignoring application responses
delete current track
end ignoring
End tell
tell application "Finder"
move theLocation to trash
end Tell


it does not empty the trash for you, that might be abit dangerous :D.. if you have a look on versiontracker.com there are a number of apps available that will allow you to map the script to a function key so you can get rid of them even quicker...also theres no checking for the type of track.. it could be expanded to confirm that you are playing a file track rather than a stream or cd
 

pcs

New member
Joined
Jul 23, 2003
Messages
1
Points
0
Another option is the Delete Files script. It takes care of deleting the current selection or current song.

A note about deleting tracks in iTunes: It works well as long as you are in the main library when deleting, but if you are in a playlist and delete the track it will only be removed from that playlist. To be sure the file disappears from iTunes, check if you are in a library, and if not, get a reference to the track (in the library) and delete that. (I didn't say this was supposed to make any sense, and this may have been fixed in iTunes 4.)

pcs
 

Tedg

New member
Joined
Jul 22, 2003
Messages
5
Points
0
Location
Virginia Beach
Website
www.sirius-beta.com
deeg said:
[Bhi ted,

try the following...

Tell application "iTunes"
copy (get location of current track) to theLocation
ignoring application responses
delete current track
end ignoring
End tell
tell application "Finder"
move theLocation to trash
end Tell
Problem is it doesn't work.
Doesn't understand "delete current track"

Best, Ted
 
Joined
Jul 1, 2003
Messages
705
Points
0
Location
Providence, RI, USA
Website
dougscripts.com
Try this

This removes all copies of the track if it is in other playlists too:

Code:
[SIZE=1]global addenda
tell application "iTunes"
	if player state is playing then
		display dialog "Are you SURE you want to delete every copy of the currently playing track?" default button 1 with icon 1
		set ofi to fixed indexing
		set fixed indexing to true
		set tid to database ID of current track
		set floc to (get location of current track)
		delete (some track of library playlist 1 whose database ID is tid)
		repeat with p from 1 to count of every playlist
			try
				delete (some track of playlist p whose database ID is tid)
			end try
		end repeat
		set fixed indexing to ofi
		set addenda to " The file has been moved to the Trash."
		tell me to delete_the_file(floc)
		display dialog "Done." & addenda buttons {"Thanks"} default button 1 with icon 1
	end if
end tell

to delete_the_file(floc)
	try
		tell application "Finder" to delete floc
	on error
		set addenda to " However, the file could not be moved to the Trash."
		try
			tell application "Finder" to open container of floc
		end try
	end try
end delete_the_file
[/SIZE]
Let me know how this works. I'm releasing a version of it at the site entitled "Whack Current Track" -- used to have such a thing for SoundJam.
 
Last edited:

deeg

New member
Joined
Jul 1, 2003
Messages
394
Points
0
Location
Swampland, UK
Problem is it doesn't work.
Doesn't understand "delete current track"

Best, Ted
hi ted,

can you tell me what version, what playlist and and default langauge you are running because it works ok here...
 

Tedg

New member
Joined
Jul 22, 2003
Messages
5
Points
0
Location
Virginia Beach
Website
www.sirius-beta.com
deeg said:
hi ted,

can you tell me what version, what playlist and and default langauge you are running because it works ok here...
iTunes 4.0 on 10.2.6, US english (but I do have SpellCatcher running)

It is a smart playlist called "female singers"

But before running, I checked it with scriptdebugger and it wouldn't compile. choking on that same line.

Best, Ted
 

deeg

New member
Joined
Jul 1, 2003
Messages
394
Points
0
Location
Swampland, UK
well thats odd..... here is the results of the event log on my system when run againsts a track on the library playlist...

tell application "iTunes"
get location of current track
alias "Stan:Users:paul:Music:iTunes:iTunes Music:Compilations:The Fast and the Furious:05 Race Against Time Part.mp3"
delete current track
current application
end tell
tell application "Finder"
move alias "Stan:Users:paul:Music:iTunes:iTunes Music:Compilations:The Fast and the Furious:05 Race Against Time Part.mp3" to trash
document file "05 Race Against Time Part.mp3" of trash
end tell


and here it is when run against a track in the smart playlist....


tell application "iTunes"
get location of current track
alias "Stan:Users:paul:Music:iTunes:iTunes Music:Madacy Music Group, Inc.:A Treasury Of Gregorian Chants Volume II:04 Alleluja, Alleluja, Laudate Dominum; Alleluja, Venite, Exultemus Domin O.mp3"
delete current track
current application
end tell
tell application "Finder"
move alias "Stan:Users:paul:Music:iTunes:iTunes Music:Madacy Music Group, Inc.:A Treasury Of Gregorian Chants Volume II:04 Alleluja, Alleluja, Laudate Dominum; Alleluja, Venite, Exultemus Domin O.mp3" to trash
document file "04 Alleluja, Alleluja, Laudate Dominum; Alleluja, Venite, Exultemus Domin O.mp3" of trash
end tell


so it's working fine at this end.. out of interest what happens it you try it in the script editor rather than script debugger ? i am running v4.0,10.2.6 and int english.. using scripteditor 2 beta 2 as the editor..
 
Last edited:
Top