I’m writing a script to erase everyone but two of the files that are downloaded into a folder.
Eratic things seem to happen. File names letters are rearranged and the script doesn’t know what to do if it is not sensing a file it’s looking for.
why should this matter? any way to improve the code and make it more stable?
set erasingfiles to {"spacer.gif", "home.gif", "shows.gif", "search.gif", "listen.gif", "about.gif", "powellsy120b.gif", "Peabody_Statuette.gif", "title.gif", "logo_pr.gifi", "logo_wpr_130w.jpg", "logo_xmradio.gif", "real1.gif", "arrow.gif"}
set filePath to (path to music folder as Unicode text) & "Audio Hijack:paparimage:pageimages:"
set thelist to list folder filePath
set item_num to my erasethefiles(erasingfiles, thelist)
on erasethefiles(this_item, this_list)
repeat with i from 1 to the count of this_list
repeat with j from 1 to the count of this_item
if item i of this_list is item j of this_item then
set filename to item i of this_item
tell application "Finder"
set file_path to (path to music folder as Unicode text) & "Audio Hijack:paparimage:pageimages:" & filename as string
delete file file_path
end tell
end if
end repeat
end repeat
end erasethefiles