プロが教えるわが家の防犯対策術!

Applescriptでドラッグ&ドロップで複数のファイルを開き、文書内に特定の単語が使われているか調べ、使われているファイルのみカラーラベルをつけたいのですが、どう記述すればよいでしょうか?よろしくお願いします。

A 回答 (1件)

on open thefileList --ドロップレット


set theNum to count text item of thefileList

--検索する文字を入力
set theSearch to text returned of (display dialog "Search" default answer "word")

repeat with i from 1 to theNum
set thefile to item i of thefileList

--ファイルの内容を読み込む
open for access thefile without write permission
set theData to read thefile
close access thefile

--検索
if (theData contains theSearch) then
display dialog "検索文字が含まれている"
tell application "Finder"
set label index of thefile to 4 -- 0にすればラベルなしになる
end tell
end if
end repeat
end open

_/_/_/

非常に大雑把なものです。
細かいエラーあるかもしれないから、参考程度に。
知っているとは思いますが、アプリケーション形式で保存しないとドロップレットになりませんので。
    • good
    • 0
この回答へのお礼

大変参考になりました。ありがとうございました。

お礼日時:2008/01/09 15:24

お探しのQ&Aが見つからない時は、教えて!gooで質問しましょう!