Every have one of those moments when you write a script and mid-testing it suddenly seems to work? Here’s one from today…
property validFileTypes : {"JPEG Image", "PDF Document"} -- Not a fan of using kind but I was going to respond to someone on the Adobe boards.
on open input_folder
set fileList to {}
tell application "Finder"
repeat with i in (item 1 of input_folder) -- ******* Here's where the magic starts... *******
set fileKind to kind of i
display dialog "" & i & return & return & "Kind: " & fileKind
if kind of i is in validFileTypes then
-- ******* Set fileList to fileList & i -- DOESN'T WORK. WHY?? *******
copy i to end of fileList -- ******* Copying it does ????? *******
end if
end repeat
if fileList ≠{} then open fileList
end tell
end open
So… You drop a folder on this. It returns a single item list with the folder as an alias. Until today, I would have requested a list of file/items of input_folder. Here the repeat loop picks them up automatically BECAUSE IT’S IN THE FINDER BLOCK. Move the repeat outside the Finder block and you’ll get an error that “item 1 of … doesn’t understand the COUNT message”! Not earth shattering, I know, but interesting.
If anyone knows, though… I’m curious as to why the set method doesn’t work for building the filelist, but the copy method does. Nigel, Bruce, Adam, JJ, anyone ???
Jim Neumann
BLUEFROG