Using multiple -iname criteria with find...

Hi,

Using find, I’m trying to search a folder for files with two different name possibilities, so I’d like to know if there is a way to use multiple -iname criteria. It’s easy to get away with this…

do shell script "find /volumes/path/to/myFolder/ -iname *abc* ; find /volumes/path/to/myFolder/ -iname *xyz*"

…which just calls find twice in one line (and works), but I’m curious if there is a more savvy syntax available.

Thanks.

I don’t think so when using the “-name” (or “-iname”) argument but using a regular expression, you can do it:

set search_terms to {"abc", "xyz"}
set the_folder to (((choose folder) as Unicode text)'s text 1 thru -2)
set found_files to (my find_in_folder(the_folder, search_terms))

on find_in_folder(the_folder, search_terms)
	set the_folder to quoted form of POSIX path of the_folder
	tell (a reference to my text item delimiters)
		set {old_tid, contents} to {contents, "|"}
		set {search_terms, contents} to {".*(" & search_terms & ").*" as Unicode text, old_tid}
	end tell
	return (do shell script "find -E " & the_folder & " -iregex " & quoted form of search_terms)'s paragraphs
end find_in_folder

Jon