set output to ""
tell application "Finder"
repeat with f in (get files of (get POSIX file "/Users/username/Folder" as alias))
if (read (f as alias) as «class utf8») contains "© 2013 copyright" then
set output to output & name of f & " - PASS" & linefeed
else
set output to output & name of f & " - FAIL" & linefeed
end if
end repeat
end tell
set b to open for access "/Users/username/Desktop/output.txt" with write permission
set eof b to 0
write output to b as «class utf8»
close access b
as «class utf8»
如果留出來,read
和write
使用主編碼,如或的MacRoman MacJapanese。 Unicode text
是UTF-16。
或者使用shell腳本:
for f in ~/Folder/*; do grep -q '© 2013 copyright' "$f" && x=PASS || x=FAIL; echo "${f##*/} - $x"; done > ~/Desktop/output.txt
grep -lv '© 2013 copyright' ~/Folder/*
作品般的魅力 - 非常感謝! – thizzle