Home > AppleScript > [ AppleScript ] ファイルリストにあるファイルに Finder でラベルを付けるサンプル

[ AppleScript ] ファイルリストにあるファイルに Finder でラベルを付けるサンプル

ファイルリスト ( テキストファイル ) に合致するファイルに Finder でラベルを付けるアップルスクリプトのサンプルです。

set Sourcetxt to (choose file with prompt "ソーステキストファイルを指定して下さい" as string) as string
set ThisFolder to (choose folder with prompt "フォルダを選んでください")

-- ファイル読み込み
set aFilePointer to open for access alias Sourcetxt
set aData to read aFilePointer as text
close access aFilePointer

-- 配列に格納
set AppleScript's text item delimiters to return
set aList to text items of aData
set AppleScript's text item delimiters to tab
tell application "Finder"
    repeat with i from 1 to count of aList
        try
            set theFile to ((ThisFolder as text) & (item i of aList) as text) as alias
            set label index of theFile to 4
        on error
            log ("error" & item i of aList)
        end try
    end repeat
end tell

ファイルリスト ( テキストファイル ) は、文字コードが Shift-JIS で、改行コードが CR で、最終行の改行無しにしておかないと動きません。

Comments:0

コメントフォーム

お気軽にコメントをどうぞ! コメントを頂けると管理人が喜びます。

情報を記憶しますか?

Trackbacks:0

Trackback URL for this entry
http://bowz.info/1785/trackback
Listed below are links to weblogs that reference
[ AppleScript ] ファイルリストにあるファイルに Finder でラベルを付けるサンプル from Bowz::Notebook

Home > AppleScript > [ AppleScript ] ファイルリストにあるファイルに Finder でラベルを付けるサンプル

Feeds
Meta
あわせて読みたいブログパーツ

Return to page top