here are some files in a folder and which ones need to be deleted, and which ones DO NOT get deleted.
05-15-20 OPEN EM.png – DELETE
05-15-20 NDP EM.png – DELETE
05-15-20 Bumper EM.png – DELETE
05-15-20_TODAY EM.png – DELETE
OPEN.png – DO NOT DELETE
NEXTDAY.png – DO NOT DELETE
BUMP1.png – DO NOT DELETE
051520_TODAY.png – DO NOT DELETE
here is my code, the delete command does NOT work.
set the_weekday to weekday of (current date) as string if the_weekday is "Friday" then set current_date to (current date) + (3 * days) else if the_weekday is "Saturday" then set current_date to (current date) + (2 * days) else set current_date to (current date) + (1 * days) end if end if --MONTH set Monthof to month of current_date as integer -- 3 set Monthof2 to Monthof as string -- 3 set x to count Monthof2 -- 1 if x is 1 then set Monthof2 to "0" & Monthof2 end if --DAY set dayof to day of current_date -- 18 set dayof2 to dayof as string -- 3 set y to count dayof2 -- 1 if y is 1 then set dayof2 to "0" & dayof end if --YEAR set yearof to year of current_date -- 2020 set yearof2 to yearof as string -- 3 set yearof3 to characters 3 thru 4 of yearof2 -- EXPORT NAME set ExportFileName to Monthof2 & dayof2 & yearof3 & "_TODAY.png" -- 051520_TODAY.png set the_promos to "OPEN.png, NEXTDAY.png, BUMP1.png, " & ExportFileName set delete_these to "" tell application "Finder" repeat with an_item in window 1 set x to name of an_item if x is not in the_promos then set delete_these to delete_these & return & x end if end repeat delete every item in delete_these -- everything works but this command end tell