I am learning AppleScript, and as a consequence, stealing other people's snippets of code and modifying it to accomplish what I want. Which means while I have a general understanding of how things work, I don't have an in depth understanding (yet). This script is, in fact, my very first AppleScript (at least since System 7; it's been a long time since I used it ).
In looking over the forums, I have seen a couple of mentions of things along this topic, but I didn't see an answer to my specific question. I have the code:
###############################
with timeout of 600 seconds
tell application "iTunes"
if selection is not {} then
set sel to selection
set oldfi to fixed indexing
set fixed indexing to true
repeat with aTrack in sel
if (class of aTrack) is file track then
set floc to (get location of aTrack)
-- set dbloc to database ID of aTrack
convert aTrack
delete (some file track of library playlist 1 whose database ID is (get database ID of aTrack))
tell application "Finder" to delete floc
end if
end repeat
set fixed indexing to oldfi
else
display dialog "No tracks selected." buttons {"Cancel"}
end if
end tell
end timeout
###############################
This script functions perfectly (there's no real error checking, but it works in general), but the delete line can take 30 or so seconds per track to complete. In other words, it's taking longer to delete the reference to the file than it is to convert it in most cases.
Is there a faster way to delete a track from the main list?
I specifically do NOT want to have to create a playlist and work from it. I'm trying to make this as "smart" as possible, so I can just hilight tracks and convert then remove them (both from iTunes, and from the disk). I have accomplished that, but the speed is... ludicrously slow.
Any suggestions on making the delete faster would be appreciated, if it's possible to do so.
In looking over the forums, I have seen a couple of mentions of things along this topic, but I didn't see an answer to my specific question. I have the code:
###############################
with timeout of 600 seconds
tell application "iTunes"
if selection is not {} then
set sel to selection
set oldfi to fixed indexing
set fixed indexing to true
repeat with aTrack in sel
if (class of aTrack) is file track then
set floc to (get location of aTrack)
-- set dbloc to database ID of aTrack
convert aTrack
delete (some file track of library playlist 1 whose database ID is (get database ID of aTrack))
tell application "Finder" to delete floc
end if
end repeat
set fixed indexing to oldfi
else
display dialog "No tracks selected." buttons {"Cancel"}
end if
end tell
end timeout
###############################
This script functions perfectly (there's no real error checking, but it works in general), but the delete line can take 30 or so seconds per track to complete. In other words, it's taking longer to delete the reference to the file than it is to convert it in most cases.
Is there a faster way to delete a track from the main list?
I specifically do NOT want to have to create a playlist and work from it. I'm trying to make this as "smart" as possible, so I can just hilight tracks and convert then remove them (both from iTunes, and from the disk). I have accomplished that, but the speed is... ludicrously slow.
Any suggestions on making the delete faster would be appreciated, if it's possible to do so.