내가 선택한 모든 트랙을 삭제하기위한 다음과 같은 애플 스크립트를 만들었습니다iTunes에서 선택한 트랙을 삭제하도록 AppleScript를 수정하려면 어떻게합니까?
property okflag : false
-- check if iTunes is running
tell application "Finder"
if (get name of every process) contains "iTunes" then set okflag to true
end tell
if okflag then
tell application "iTunes"
if selection is not {} then
repeat with this_track in selection
try
try
set cla to class of this_track
set floc to (get location of this_track)
delete this_track
on error error_message number error_number
display alert error_message message ("Error number: ") & error_number & "."
end try
if cla is file track then
my delete_the_file(floc)
end if
end try
end repeat
end if
end tell
end if
to delete_the_file(floc)
try
-- tell application "Finder" to delete floc
do shell script "mv " & quoted form of POSIX path of (floc as string) & " " & quoted form of POSIX path of (path to trash as string)
on error
display dialog "Track deleted, but could not be moved to trash" buttons {"Hmm"} default button 1 with icon 1
end try
end delete_the_file
내가 단일 항목을 선택하면 그것은 잘 작동하지만 내가 이상 하나를 선택했을 때 얻을 "의 위치를 가져올 수 없습니다 선택 항목 2 "(오류 번호 -1728). 나는 이것이 트랙을 삭제함으로써 스크립트의 인덱스가 손상되어서 이것이라고 생각한다.
tell application "iTunes"
if selection is not {} then
set to_delete to {}
repeat with this_track in selection
try
set cla to class of this_track
set floc to (get location of this_track)
if cla is file track then
set pair to {this_track, floc}
set to_delete to to_delete & pair
end if
end try
end repeat
repeat with pair in to_delete
set the_track to item 1 of pair
set floc to item 2 of pair
delete the_track
my delete_the_file(floc)
end repeat
end if
end tell
을하지만 그때 나는 응용 프로그램의 "iTunes"의 선택 항목 1의 항목 하나를 가져올 수 없습니다 '얻을 :
은 내가 트랙 내 자신의 목록을 먼저 삭제 할 수있게하려고 거라고 생각했다. ' 나는 문제가 "this_track"이 클래스 트랙의 객체가 아니라 선택 항목이라고 생각한다. 선택 항목에서 실제 트랙 객체를 얻으려면 어떻게해야합니까?해결 방법이 표시되지 않으면 디버깅 또는 다른 제안 사항에 대한 정보를 보내 드리겠습니다.
나는 당신의 변화를 만들어 오류를 가지고 : 여기
이 버그가 제거 된 두 번째 스크립트의 버전의 '<답변을 업데이트 주셔서 감사합니다. AppleScript를 디버깅하는 방법을 알아야 할 것 같습니다. 질문을하겠습니다. –