I am trying to write code that deletes files from a specified location and empties into the trash. If I use the direct string it works but when I try to add a variable it does not. Could someone help show me what I'm doing wrong?
When I tried to look up the error code number at the bottom, it didn't give me much insight.
Valid
tell application "Finder"
delete (every item of folder "Macintosh HD:Users:sme0219:Pictures:Camera" whose name contains ".png")
end tell
Invalid
tell application "System Events"
set userName to name of current user
set compName to name of startup disk
end tell
tell application "Finder"
delete (every item of folder compName & ":Users:" & userName & ":Pictures:Camera" whose name contains ".png")
end tell
Error Report
error "Can’t get {folder "Applications" of startup disk of application "Finder", folder "Library" of startup disk of application "Finder", folder "System" of startup disk of application "Finder", folder "Users" of startup disk of application "Finder", ":Users:", "sme0219", ":Pictures:Camera"} whose name contains ".png"." number -1728