bryceratops88

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

Close

Q: choose multiple folders with choose menu and empty their contents

  • All replies
  • Helpful answers

  • by Jacques Rioux,Solvedanswer

    Jacques Rioux Jacques Rioux Sep 23, 2016 8:08 AM in response to bryceratops88
    Level 4 (3,418 points)
    Mac OS X
    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"}

    ---

  • by bryceratops88,

    bryceratops88 bryceratops88 Sep 25, 2016 9:31 AM in response to Jacques Rioux
    Level 1 (4 points)
    Sep 25, 2016 9:31 AM in response to Jacques Rioux

    Thank you so much. Worked like a charm.