AppleScript issues deleting the contents of a folder

I have the following AppleScript that deletes all the contents of a specific folder before I copy new files into it. Occasionally, the script will end up placing the files to be deleted in the root iCloud directory instead of the trash. I know that this is a known issue, but I'm not sure how to adjust the script to prevent this from happening. Any guidance would be appreciated. Here is the script.


tell application "Finder"

ignoring application responses

delete (every item of folder "Macintosh HD:Users:mydrive:Documents:myfolder")

delay 5

end ignoring

MacBook Pro (M4)

Posted on Aug 23, 2025 12:55 PM

Reply
1 reply

AppleScript issues deleting the contents of a folder

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.