Never seeking downloads folder with apple script
Tags: macos, applescript, productivity
Published: 2020-04-25 06:29:38

---
title: Never seeking downloads folder with apple script
tags: #macos #applescript #productivity
published: true
author: kazuooooo
slide: false
---

How many times do you download something ever?

* Download any new software
* Download photos and icons
* Download the file sent to you by email
* ...etc.

And what is the one thing you must do after you download it?
That's right.

**Open the download folder! **

I'm sure I'll do it, I'd love to meet someone who doesn't open the download folder after downloading it 😜

I think most people do this, don't they?

1. cmd + space to find finder
2. select the download folder
3. move or open files

This is such a hassle and a waste of time, isn't it?
This time, I'll show you how to automate the process of opening this download folder using apple script!

## How to do it

This time, we'll use a feature called [WatchingFolders]([Mac Automation Scripting Guide: Watching Folders](https://developer.apple.com/library/archive/documentation/AppleScript/Conceptual/AppleScriptLangGuide/introduction/ASLR_intro.html)) in apple script.

About apple script itself, you can see [here](http://tonbi.jp/AppleScript/Introduction/01/).

1. First of all, you need to create an apple script by using the script editor, which is the editor of apple script.
Just 5 lines of script will save your time.

```applescript
on adding folder items to theAttachedFolder after receiving theNewItems
	tell application "Finder"
		open theAttachedFolder
	end tell
end adding folder items to
```

Something like this.

<img width="350" alt="open_directory_on_add_item_ and _Never_seeking_for_download_folder.png" src="https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/71154/688720a9-18ae-e3a7-c382-774a4ff64211.png">


To explain a little since this is a technical article, when a file is added to a folder, the event handler is called and the object of the folder is put into theAttachedFolder.

```applescript
on adding folder items to theAttachedFolder
```

to open that folder in the Finder.

```applescript
tell application "Finder"
	open theAttachedFolder
end tell
```

2. Once the script is created, save it. At this time, it is important to note that you need to save it to one of the folders of

* /Library/Scripts/Folder Action Scripts/ ## Available to any user
* ~/Library/Scripts/Folder Action Scripts/ ## Current user only

The name can be anything, but this time I chose open_directory_on_add_item.
(If you don't have Folder Action Scripts, you can create your own one with the same name.)

3. Apply the script to the Download folder after saving it.
  1. Control-click the folder in Finder.
  2. Choose Folder Actions Setup from the contextual menu.
  3. Choose a script to connect to the folder and click Attach.
<img width="254" alt="Folder action settings_and_search.png" src="https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/71154/3552ebfc-7f29-5baf-3137-dacf9b64001d.png">

Also make sure that Use Folder Actions is checked.

<img width="244" alt="Folder Action Settings_and_Never_seeking_for_download_folder.png" src="https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/71154/2d934cfd-2edf-a434-2a18-e4efbb6e43df.png">

We're ready to go!

## Operation check
Finally, let's make sure it works!
I'm going to try to download some kind of icon, whatever it is.
[Wombat - Free animals icons](https://www.flaticon.com/free-icon/wombat_427526?term=wombat&page=1&position=5)
The download folder should open automatically when it completes!

Now you're free from the pain of looking for the download folder! You have to try it!