2
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

複数フォルダの指定から、右クリックで各フォルダを RAR 圧縮するサービスを macOS の Automator で作る

Last updated at Posted at 2018-07-30

RAR のインストール

$ brew cask install rar

うまくインストールできないときは以下のオプションで対応する

$ brew cask install --force rar

RAR コマンドのパスを調査

$ which rar
/usr/local/bin/rar

rar コマンドは /usr/local/bin/ に存在した。

サービスの作成

  1. 「Automator」の「新規作成」で「サービス」を選択
  2. 「サービスは、次の選択項目を受け取る:」には「フォルダ」を指定、「検索対象:」には「Finder」を指定
  3. 左ペインの「アクション」から「シェルスクリプトを追加する」を検索・選択し、ドラッグ・アンド・ドロップで右ペインへ入力
  4. 「シェル:」には「/bin/bash」を指定、「入力の引き渡し方法:」には「引数として」を指定
  5. 入力欄に以下のシェルスクリプトをコピー&ペースト
  6. 好きなサービス名を付けて保存
rar-comp.sh

USRBIN="/usr/local/bin/"
TITLE="RAR圧縮"
MESSAGE="完了"

for f in "$@"
    do
        EXEDIR="${f%/*}"
        DIRNAME="${f##*/}"
        cd "${EXEDIR}"
        "${USRBIN}"rar a -m5 -rr5p "${DIRNAME}".rar "${DIRNAME}"
        osascript -e "display notification \"${DIRNAME} ${MESSAGE}\" with title \"${TITLE}\""
    done

参考 URL: Terminal を Automator でよく行う処理を簡単サービス化

使用方法

  1. フォルダ選択後に右クリック、プルダウンメニューから RAR 圧縮サービスを実行する
  2. RAR圧縮が完了する毎に「通知」で表示される

サービスの削除

  1. システム環境設定>キーボード>キーボードショートカット>サービスを選択
  2. 削除したいサービスを選択して右クリック
  3. プルダウンメニューの「Finder に表示」を選択
  4. Finder 上で該当ファイルを削除

以上

2
1
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
2
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?