Guys,
I have this piece of code where I check if the dropped item on the application icon is a folder or not. Here is the code
on open my_folder
tell application "System Events" to set theType to (get class of item (my_folder as text))
if theType = "cfol" then
MyFunc(my_folder)
else
display dialog "There was an error
Please drop only folders
" buttons {"Ok"} with icon stop
end if
end open
The issue is that when I drop a file on the application, it goes into the else block. But when I drop a folder, it still goes into the else block. What am I doing wrong?
Hi,
the literal string “cfol” is no valid class specifier
To proceed a value outside a System Events tell block, coerce the class name to string
on open my_folder
tell application "System Events" to set theType to (get class of item (my_folder as text) as text)
if theType = "folder" then
MyFunc(my_folder)
else
display dialog "There was an error
Please drop only folders
" buttons {"Ok"} with icon stop
end if
end open
I’m always using this way
on open my_folder
set {folder:Fo, package folder:Pa} to info for my_folder
if Fo and not Pa then
MyFunc(my_folder)
else
display dialog "There was an error
Please drop only folders
" buttons {"Ok"} with icon stop
end if
end open