Q: 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
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"}
---
Posted on Sep 23, 2016 8:08 AM