Use AppleScript to automatically close Safari's Downloads window

September 22, 2010

Thanks to this post and it’s comments you can automatically close Safari’s Downloads window. Create the following AppleScript and place it in /Library/Scripts/Folder Action Scripts.

on appIsRunning(appName)
  tell application "System Events" to (name of processes) contains appName
end appIsRunning

on adding folder items to this_folder after receiving added_items
    if appIsRunning("Safari") then
      tell application "Safari"
        repeat with w in windows
          if name of w is "Downloads" then
            set isdocument to true
              set d to document of w
              set the result to d
            on error
              set isdocument to false
            end try

            if (not isdocument) then
              tell w to close
            end if
          end if
        end repeat
      end tell
    end if
  end try
end adding folder items to

Then navigate to your home directory, right click on Downloads and select Folder Actions Setup... to add this script to that folder.

Now, as you download files to this folder the script will be run and the window closed. I find it takes a second or two, but at least I don’t have to keep closing it myself!