Trying to run down my error that’s coming up on a recursive call to my delete function. If I select an individual file, all works fine. If I select the folder that file (and others) is contained in, it errors out when it starts looking at the same file that if I run with that as the selection is fine.
With the limited debugging ability of AS, I’ve managed to (I think) find what the problem is; I just don’t know how to correct it. First the script (please ignore the logs and dialogs as they are for debugging):
on Delete_Selections(selected_items)
log "Begin Delete_Selections"
# display dialog "CurrentItem:" & (selected_items)
repeat with tmp_File in selected_items
# display dialog "Selection:" & (tmp_File)
log tmp_File
try
log "TRY set tmp_Kind"
set tmp_Kind to kind of tmp_File
on error errString
log "ERROR set tmp_Kind: " & errString
set tmp_Kind to "Folder"
end try
log "TRY end"
log tmp_Kind
if (word 1 of tmp_Kind) = "Application" then
beep 5
# open tmp_File using application file id "com.apple.AppDelete"
else if tmp_Kind = "Volume" then
beep 4
# eject
else if tmp_Kind = "Folder" then
display dialog "recursive with:" & (tmp_File)
try
log "Try"
tell application "Finder" to set theItems to count of items of tmp_File
on error errString
log "On Error: " & errString
tell application "Finder" to set theItems to count of files of tmp_File
end try
log "End Try"
display dialog "Folder " & (tmp_File) & "has " & (theItems) & " items in it."
if theItems > 0 then
set tmp_Files to my get_folder_list(tmp_File, file_types, with_subfolders, inc_folders, use_posix_path)
log tmp_Files
my Delete_Selections(tmp_Files)
beep 3
end if
else
beep 1
# move tmp_File to trash
end if
end repeat
end Delete_Selections
The result of tmp_File when I run with just the file selected is (note the 3rd line):
(Begin Delete_Selections)
tell application “Finder”
(document file AccountPrefs.plist of folder Default of folder Users of folder Adium 2.0 of folder Application Support of folder Library of folder angelomi of folder Users of startup disk)
end tell
(TRY set tmp_Kind)
tell application “Finder”
get kind of document file “AccountPrefs.plist” of folder “Default” of folder “Users” of folder “Adium 2.0” of folder “Application Support” of folder “Library” of folder “angelomi” of folder “Users” of startup disk
→ “XML Property List File”
end tell
(TRY end)
(XML Property List File)
When I run it with the parent folder selected, it runs fine and gets the list of files in the folder and returns it. Then when I recursively call Delete_Selections with my new list, the result is (note the 2nd line is tmp_File):
(Begin Delete_Selections)
(Macintosh HD:Users:angelomi:Library:Application Support:Adium 2.0:Users:Default:AccountPrefs.plist)
(TRY set tmp_Kind)
(ERROR set tmp_Kind: Can’t get kind of “Macintosh HD:Users:angelomi:Library:Application Support:Adium 2.0:Users:Default:AccountPrefs.plist”.)
(TRY end)
(Folder)
As I’ve not been using AS that much I’m not sure what’s going on except that the variable is obviously in a different format from
(document file AccountPrefs.plist of folder Default of folder Users of folder Adium 2.0 of folder Application Support of folder Library of folder angelomi of folder Users of startup disk)
to
(Macintosh HD:Users:angelomi:Library:Application Support:Adium 2.0:Users:Default:AccountPrefs.plist)
Just don’t know why nor how to fix it. Any suggestions of nudges in the right direction would be appreciated.