I have a folder that I want to select all of the files accept for the ones that end with “scan”.
here is what I have, but it still imports those images:
tell application "Finder"
set theImageList to every file of theFolder whose name does not end with "scan" and ¬
the file type obsolete is "TIFF" or the file type obsolete is "EPSF" or ¬
the file type obsolete is "PICT" or the file type obsolete is "JPEG"
if class of theImageList is not list then set theImageList to theImageList as list
set theImageNameList to the name of every file of theFolder whose name does not end with "scan" and ¬
the file type obsolete is "TIFF" or the file type obsolete is "EPSF" or ¬
the file type obsolete is "PICT" or the file type obsolete is "JPEG"
if class of theImageNameList is not list then set theImageNameList to theImageNameList as list
end tell
Hi Kevin,
Try running this in the Script Editor:
set x to true not x and false or false or true
No matter what x is this is always true (ie. not true and false is false, false or false is false, false or true is true). So your script should work if you put parenthesis like this:
not x and (false or false or true)
Here the right side of the and is done first before the and.
Also, I kind of shortened your script which should cut down your typing in the future. Lastly, what is ‘obsolete’? It shows up in my syntax check as an application keyword, but, I can’t remember ever seeing it.
property type_list : {"TIFF", "EPSF", "PICT", "JPEG"}
set theFolder to (choose folder)
tell application "Finder"
set theImageList to ¬
(every file of theFolder ¬
whose name does not end with ¬
"scan" and file type is in type_list)
if theImageList is {} then
set theImageNameList to {}
else
set theImageNameList to ¬
(name of every file of theFolder ¬
whose name does not end with ¬
"scan" and file type is in type_list)
end if
end tell
gl and thanks,
Kel.
ps. The statement (every file of the_folder whose …) always returns a list that maybe empty. The statement (name of every file of the_folder whose …) will return an error if the folder is empty I think.
Have you considered using Akua’s “the entries in”? The code would be no longer than Kel’s but, perhaps of interest to you, the speed would be considerably improved - partly because you would no longer be telling the Finder to do anything - almost always a good idea!
: Lastly, what is ‘obsolete’? It shows up in my syntax check as
: an application keyword, but, I can’t remember ever seeing it.
It sometimes appears in scripts that were compiled with an older version of the application being addressed. When the script from which Kevin’s is adapted was compiled, the Finder’s ‘file type’ keyword compiled to a different token. Since then, the Finder’s AppleScript engineers have decided that the current token would be better and so ‘file type’ now compiles to this. In order that scripts compiled with the old token shouldn’t immediately break, the old token has been left in place and still works, but has been given the new keyword ‘file type obsolete’. When the compiled script is opened in a script editor in the presence of a recent version of the Finder, its the old token’s new keyword that’s decompiled into the text you see. If you edit out all the 'obsolete’s and recompile the script, the new token will be used instead.