Hey all. I’ve come up with a script - I’ve introduced it before on here - which is meant to perform the following task: Make aliases of all files in a given directory that do not appear on a delimitted tabbed text file. Basically, the script knows to exclude the file names in that .txt file while making aliases of every other file in the chosen directory and spitting the aliases out into a common folder.
I had success with it in limited testing, but in more complicated file structures with more than a few folders and several levels, it seems indiscriminate. I need to have it just target the names of files NOT appearing on that list rather than all the folders in that directory and everything in them. I think this is the problem that causes the script to provide so many false positives to the point of being worthless - but am I also missing something else here?
I’ve posted the script below. It’s very short and to-the-point, at least for a script I’ve coded myself. I may have approached it in a klunk way though. Thanks for any help or insight you might have:
tell application "Finder"
set folderRef to (make new folder at desktop with properties {name:"Not In Their List"})
set fileRef to (choose folder)
set textFile to (choose file of type "TEXT") as text
-- Exclude list
set excludedList to paragraphs of (read file textFile)
set pSF to quoted form of 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
set allList to every file of fileRef whose name is not in excludedList
make new alias file at folderRef to every item of allList
end tell