Select files in Finder from a text list

Hello again,

I have several thousands of files that are in a folder and I want to select the ones that are in a text list.

The files in my folder are like this:

My text file list is:

I tried with the next script but gave the error 1731 “An unknown type of object was detected.”


set theSourceFolder to (choose folder with prompt "Select a folder:")
set theFileList to choose file with prompt "Select file: "

tell application "Finder"
	open theSourceFolder
	select (every item of theSourceFolder whose name is in theFileList)
end tell

What am i missing?

Any help would be appreciated. Thank you in advance.

Alejandro

Model: mac mini 2011
AppleScript: 2.6.1
Browser: Safari 537.36
Operating System: Mac OS X (10.9)

the variable theFileList contains the file to the text file but not it’s content. To get it’s contents you can read a file and when it is separated by newlines or returns you can use the paragraph property.

set theFileListPath to choose file with prompt "Select file: "
set theFileList to paragraphs of (read theFileListPath)

Now theFileList contains all file names.

Thank you very much!

With your correction the script is running ok.