Filtering "entire contents" - possible?

We often use this construction to produce a list of aliases to all of the files at any depth in an enclosing folder:

set F to choose folder
tell application "Finder" to try
	set tF to files of entire contents of F as alias list
on error
	set tF to files of entire contents of F as alias as list
end try

But suppose we only want files of a particular type? Is there a construction of a filter statement that works on “entire contents”?

Without that, you have to resort to this (illustrated for mpeg files)

set Fldr to choose folder
set F to paragraphs of (do shell script "mdfind -onlyin " & quoted form of POSIX path of Fldr & " \"kMDItemContentType == 'public.mpeg'\"")
set tF to {}
repeat with I in F
	set tF's end to (POSIX file I) as alias
end repeat

:

Adam, I may be misunderstanding your question entirely but.

set inputFolder to choose folder with prompt "Where is the top level folder of PFD's?" without invisibles
tell application "Finder"
	try
		set filesList to (files of entire contents of inputFolder whose name extension is "pdf") as alias list
	on error -- only one file
		set filesList to (files of entire contents of inputFolder whose name extension is "pdf") as alias as list
	end try
end tell

does this not do wht you want

I see the problem, Mark, thanks.

Here’s what I was trying:

set TI to "public.mpeg"
set searchFolder to (choose folder)
tell application "Finder" to try
	set tF to (files of entire contents of searchFolder whose type identifier is TI) as alias list
on error e
	display dialog e
	set tF to (files of entire contents of searchFolder whose type identifier is TI) as alias as list
end try

But that fails because the Finder doesn’t know what a file’s type identifier is, that’s in “info for”.

This solves it:

set TI to "MPEG Movie"
set searchFolder to (choose folder)
tell application "Finder" to try
	set tF to (files of entire contents of searchFolder whose kind is TI) as alias list
on error e
	display dialog e
	set tF to (files of entire contents of searchFolder whose kind is TI) as alias as list
end try

Addendum: Don’t you wish the Finder and System Events could agree on file specifications?

Yes. And you won’t catch it if theres only one .mpeg you still have “type identifier” but i’ll forgive you that as it was you who told me the on error – only one file trick

:rolleyes:

I fixed it in the offending post.