LoginSignup
4
4

More than 3 years have passed since last update.

Automator + AppleScriptでサブフォルダーを作る

Last updated at Posted at 2020-01-06

目標

見積書・請求書・発注書/検収書のサブフォルダーを右クリックのプルダウンメニューから一発で作りたい。

環境・アプリ・言語

  • OS:macOS Mojave(v10.14.6)
  • アプリ:Automator
  • 言語:AppleScript

手順概略

  1. Automator立ち上げ
  2. 新規作成
  3. クイックアクションを選択
  4. ワークフローを選択
  5. AppleScriptを実行`をドラッグドロップ
  6. AppleScriptを記述
  7. 名前をつけて保存

手順詳細

1. Automator立ち上げ

$ open /Applications/Automator.app

or

Applicationsフォルダーから探して立ち上げる。

2. 新規作成

ファイル>新規を選択

新規作成.png

3. クイックアクションを選択

クイックアクションを選択して、選択ボタンを押下

クイックアクション.png

4. ワークフローを選択

ワークフロー:フォルダ 検索対象:Finder.appを選択

スクリーンショット 2020-01-06 17.43.38.png

5. AppleScriptを実行`をドラッグドロップ

アクション>ライブラリ>Automatorの中からAppleScriptを実行をドラッグドロップ

スクリーンショット 2020-01-06 17.45.22.png

6. AppleScriptを記述

以下AppleScriptをコピペ

tell application "Finder"
    try
        set currentfolder to (folder of the front window as string)
    on error
        display dialog "フォルダーに移動して、スクリプトを実行してください。" with icon stop buttons {"Cancel"}
    end try
    try
        make new folder at currentfolder with properties {name:"見積書"}
        make new folder at currentfolder with properties {name:"請求書"}
        make new folder at currentfolder with properties {name:"発注書・検収書"}
    on error
        display dialog "すでに作成済みです" with icon stop buttons {"Cancel"}
    end try
end tell

スクリーンショット 2020-01-06 17.48.59.png

7. 名前をつけて保存

名前を付けて保存

スクリーンショット 2020-01-06 17.51.42.png

実行してみる

  1. 作りたいディレクトリを右クリック
  2. 見積書フォルダ作成を選択
  3. できた\(^o^)/

スクリーンショット 2020-01-06 18.00.06.png
スクリーンショット 2020-01-06 18.00.41.png


おまけ

右クリックメニューのサービスで階層になるアイテムの個数を設定する

$ defaults write -g NSServicesMinimumItemCountForContextSubmenu -int 20
$ killall Finder

シンプルに生きたい

4
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
4