I'm a bit late to this party, but...
Shell scripting is no problem as someone mentioned. Perl, Python, or Ruby would make short work of this task.
Scripting TextEdit is a pretty sad business but adequate for your purpose. I would prefer to use an editor with a scriptable search like Tex-Edit Plus or TextWrangler.
Personally I'd use the Satimage.osax for convenience, speed, and versatility.
(If your system is Mavericks you can use a ASObjC-Library for the regex instead of the Satimage.osax, and I believe Shane has posted one.)
A couple of examples are appended.
-------------------------------------------------------------------------------------------
# Nice shareware styled text editor (not limited when unregisterd).
# Highly scriptable.
-------------------------------------------------------------------------------------------
# REQUIREMENT: File must start and end with a CR.
# It is possible to ensure this in the script if necessary.
-------------------------------------------------------------------------------------------
set srcfolder to alias "hfs:path:to:your:folder:"
set fileNameList to list folder srcfolder without invisibles
set missingFileNameList to {}
set foundFileNameList to {}
repeat with i in fileNameList
set findStr to return & i & return
tell application "Tex-Edit Plus"
tell front document
if (search looking for findStr) = false then
set end of missingFileNameList to contents of i
else
set end of foundFileNameList to contents of i
end if
end tell
end tell
""
end repeat
{foundFileNameList, missingFileNameList}
-------------------------------------------------------------------------------------------
# It must be installed for the script to work!
-------------------------------------------------------------------------------------------
# Way faster and more versatile than using Tex-Edit Plus.
-------------------------------------------------------------------------------------------
set srcfolder to alias "hfs:path:to:your:folder:"
set fileNameList to list folder srcfolder without invisibles
set missingFileNameList to {}
set foundFileNameList to {}
set AppleScript's text item delimiters to ""
tell application "TextEdit"
set refFileNameList to text of front document
end tell
set refFileNameList to change "^$\\s+" into "" in refFileNameList with regexp
set refFileNameList
to change "\\s+\\Z" into "" in refFileNameList
with regexp
repeat with i in fileNameList
set regEx to change "([\\[\\]{}()^.?*+-])" into "\\\\\\1" in (contents of i) with regexp
set regEx to "^" & regEx & "$"
try
set _found to find text regEx in refFileNameList with regexp
set end of foundFileNameList to contents of i
on error
set end of missingFileNameList to contents of i
end try
end repeat
{foundFileNameList, missingFileNameList}
-------------------------------------------------------------------------------------------