tybx

ダウンロード先をSpotlightコメントに入力してくれるApple Script

2件のコメント

Safariでダウンロードしたファイルのダウンロード先をSpotlightコメントに入力してくれるプラグインとして、DownloadComment(リンク先はMacUpdate)がありますが、環境によってはSafari5で使えない上に開発も終わってしまったようです。

その代わりになるApple ScriptがTip: Automatically Add URL To A Downloaded File As Spotlight Commentに載っていたので、紹介しようと思います。

  1. 以下のコードをスクリプトエディタにコピペします。
    on adding folder items to thisFolder after receiving someItems
        if (count items of someItems) ≠ 1 then return
        set itemAlias to (item 1 of someItems) as alias
        do shell script "mdls " & (quoted form of (POSIX path of itemAlias))
        set urls to the result
        set oldDelimiters to AppleScript's text item delimiters
        set AppleScript's text item delimiters to {"kMDItemWhereFroms"}
        try
            set urls to (text item 2 of urls)
            set AppleScript's text item delimiters to {quote}
    
        if (count urls's text items) ≤ 3 then
            set urls to (text item 2 of urls)
        else
            set urls to (text item 4 of urls)
        end if
    
        set myFile to itemAlias as string
        tell application "Finder"
            set the comment of file myFile to urls
        end tell
        on error
            set AppleScript's text item delimiters to oldDelimiters
            return -- urls don't exist
        end try
    end adding folder items to
  2. 適当な名前を付け(ex. Add Spotlight Comment with URL)、ユーザフォルダのLibrary/Scripts/Folder Action Scripts/以下に保存します。
    sewindow.png
    sesave.png
  3. フォルダアクションでダウンロードフォルダにスクリプトを設定します。
    faset.png

これでダウンロードしたファイルのSpotlightコメントにダウンロード先が入力されます。
exinfo.png

DownloadCommentと違って正確なダウンロード先とはいかないみたいですが、DownloadCommentが動かない方には便利なスクリプトではないでしょうか。

投稿者: pinacol

2010.10.31 at 8:16 pm

カテゴリー: Article

タグ: ,

コメント / トラックバック2件

RSS でコメントを購読する

  1. さっそく設定してみました。
    とても便利ですね、情報ありがとうございます!

    ユーザーのライブラリに該当フォルダが無かったのでフォルダを作成してスクリプトを保存したのですが、フォルダ名の最後に「s」が入ってないと認識してくれませんでした。 「Folder Action Scripts」←

    ぴろ

    2010.11.03 3:29 pm

  2. コメントありがとうございます。

    情報ありがとうございました。
    教えていただいた点を修正しました。

    pinacol

    2010.11.03 5:47 pm


コメントする

以下に詳細を記入するか、アイコンをクリックしてログインしてください。

WordPress.com ロゴ

WordPress.com アカウントを使ってコメントしています。 ログアウト / 変更 )

Twitter 画像

Twitter アカウントを使ってコメントしています。 ログアウト / 変更 )

Facebook の写真

Facebook アカウントを使ってコメントしています。 ログアウト / 変更 )

%s に接続中

フォロー

Get every new post delivered to your Inbox.