choose multiple folders with choose menu and empty their contents

Hello all,


new to applescript and want to create a choose file menu where I can choose more than one folder and purge their contents. There would be a dialog box at the end letting me know that the folders have been purged. The script I have works for an individual folder:


tell application "Finder"


close every window

open (choose folder with prompt "which folder(s) should i purge?" multiple selections allowed "True" default location "/users/bryceratops/")

set a to front Finder window

move every item of a to trash


close front Finder window

end tell

tell application "Finder"

display dialog "folder(s) purged." buttons {"ok"}

end tell

But Im having a hard time setting up this script to open, purge, & close every finder window If I've selected multiple folders in the choose menu.

Any ideas?

Cheers

Posted on Sep 22, 2016 11:59 PM

Reply
2 replies

Sep 23, 2016 8:08 AM in response to bryceratops88

Hello,


Put the result of the "choose folder" command into a variable (no need to open these folders).

----

set tFolders to (choose folder with prompt "which folder(s) should i purge?" default location "/users/bryceratops/" with multiple selections allowed)

tell application "Finder"

repeat with thisDir in tFolders

delete items of thisDir -- trash

end repeat

end tell

activate

display dialog "folder(s) purged." buttons {"ok"}

---

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

choose multiple folders with choose menu and empty their contents

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