exclusion in alias-making script

Hey all.

I’ve cobbled together my first “original” script. I have to credit this to my fellow posters here, who have given me direct guidance and whose past posts I’ve studied as I develop my - still elementary - scripting technique.

I’m attempting to make aliases of files in a directory and dump them in a common folder. The hitch is excluding a list of files and that’s where I’ve gotten hung up. I just want to have it use a list of files for the script to ignore when making the aliases.

Here’s what I’ve come up with. I think I’m pretty close, but the script just doesn’t seem to know what to do with the “allList” variable - the one from which the file names will be excluded.

Anyhow, thanks for all your help thus far. Please find the script below.

tell application "Finder"
	set folderRef to (make new folder at desktop with properties {name:"Not In Their List"})
	set fileRef to (choose folder) as string
	set textFile to (choose file of type "TEXT") as text
	
	-- Exclude list
	set excludedList to paragraphs of (read file textFile)
	
	
	tell application "Finder" to set allList to every item of fileRef whose name is not in excludedList
	set pSF to POSIX path of fileRef
	set tPaths to {}
	repeat with aFile in excludedList -- a form that's faster because you don't have to count the list
		try
			set end of tPaths to POSIX file (do shell script "mdfind -onlyin " & pSF & space & quoted form of aFile) as alias
		on error -- no file by that name was found in the searchfolder.
			set end of tPaths to aFile & " N/A"
		end try
	end repeat
	
	make new alias file at folderRef to every item of allList
	
	repeat with i from 1 to number of items in allList
		
	end repeat
	
	
end tell

The error is that you’ve coerced fileRef to a string, with makes it pretty useless afterwards in this case. You want to leave it as an alias. So remove “as string”.

Also (minor), you do not need to tell the Finder again, in the allList line; you’re already inside a Finder tell block.

The whole business after the allList line (except for the alias file line) seems to be going thru the exclusion list and creating a list of the ones that were not used for exclusion. I don’t really see why, for one thing. Nor do I see why you do that before you create the alias files. Nor why you created this list, but did nothing with it, not even returned it at the end to see it. But I don’t really know its purpose?

In any case, you also need to use the quoted form for the folder path, in case it has spaces:
set pSF to quoted form of POSIX path of fileRef

I see no reason for the last repeat block (2 lines). It isn’t doing anything.