I found a mistake in the process_item handler.
The info for command expects an alias outside a Finder tell block,
but the list of the folder items are file specifiers.
...
repeat with this_item in these_items
tell (info for this_item as alias) to set {fType, fExt} to {file type, name extension}
if fType is in type_list or fExt is in extension_list then
set esistenza to true
...
So, we are near the end of this script. I can see the light in the end…
Final script from Stefank works fine, but there is a logical problem: the process_item() handler is calling many times, so, if I have one or more folders and some other file in drop, the process_item() is coming two times. Not good (the handler process_item() has a dialog box: it’s boring to insert all choise two times
Better is to create a list of file that contains ALL file inside the folder/s and the file dropped together.
Here you are the handler
on set_folder(these_items)
set theFiles to {}
repeat with this_item in these_items
set {isAlias, isFolder} to {alias, folder} of (info for this_item)
if (isAlias is false and isFolder is true) then
tell application "Finder"
set my_items to every file of this_item
end tell
set theFiles to (theFiles & my_items)
else
set end of theFiles to this_item as alias
end if
end repeat
process_item(theFiles) -- the only calling for handler
end set_folder
Now, problem is that in the process_item(), when script try to get info from file (that is inside a folder dropped) an error says: “Can’t find file (name of file)”. Nothing appears if I drop only file.
I think that the error can be in this command
set theFiles to (theFiles & my_items)
Where script try to add file from a folder (myfile) to previuous list of file (theFiles).
NB: I don’t report all the script because it’s too long and boring, but if someone want it…
if you want a straight list of the files, try this:
property type_list : {"JPEG", "TIFF", "PNGf", "PICT"}
property extension_list : {"jpg", "jpeg", "tif", "tiff", "png", "pict"}
on open these_items
set_folder(these_items)
end open
on run
set these_items to choose file with prompt "Select file" with multiple selections allowed without invisibles
process_item(these_items)
end run
on set_folder(these_items)
local theFiles
set theFiles to {}
repeat with this_item in these_items
set {isAlias, isFolder} to {alias, folder} of (info for this_item)
if (isAlias is false and isFolder is true) then
tell application "Finder" to set theFiles to theFiles & (get files of this_item)
else
set end of theFiles to this_item
end if
end repeat
process_item(theFiles)
end set_folder
on process_item(these_items)
set esistenza to false
repeat with this_item in these_items
tell (info for this_item as alias) to set {fType, fExt} to {file type, name extension}
if fType is in type_list or fExt is in extension_list then
set esistenza to true
else
set esistenza to false
end if
end repeat
end process_item