Delete files from list created by Finder?

Here’s a problem that I hope has a solution but which I can’t figure out.

I have a script that acts like a folder action script but (for the sake of speed) is run by a launch daemon.

Near the beginning of the script I have some lines like these:

tell application "Finder" to set theseItems to every item in thisFolder
	repeat with i in theseItems
		set thisFile to i as alias

The script checks for files whose names end in .ps, .tmp, and only acts on files with specific extensions.

When it acts on a file with the extension .ps, it also checks for the existence of a file named something.file, and reads that file in order to determine what to do with the something.ps file. It then deletes something.file.

This works perfectly well, except for one thing:

When the script sets theseItems to every Item in thisFolder, those items include something.file, and when it runs the repeat loop a second time, and runs the line “set thisFile to i as alias”, the script tries to set something.file to i as alias - but “i” (something.file) now doesn’t exist, so the script fails with an error message.

How can I remove something.file from the list of theseItems so that the repeat loop will not try to process it?

I hope I’ve made this question clear. Thanks for any help.

Why not just exclude something.file?


tell application "Finder" to set theseItems to every item in thisFolder whose name ≠ "something.file"

That works perfectly. Thank you! I thought the solution would be complicated and difficult, and it turns out to be simple.

Because “something.file” was just an example, this is what works in my script:


tell application "Finder" to set theseItems to every item in thisFolder whose name does not end with ".file"

Thank you again!