I’m having a problem working with files dropped onto a droplet. I think what’s going on is Applescript refers to the files as a list and therefore cannot read a file-type, name extension, or really any helpful info to determine what kind of file it is. Below is the part of the script. Thoughts??
on open theFiles
tell application "Finder"
repeat with i from 1 to count theFiles
if (file type of theFiles is not "IDp4") and ¬
(file type of theFiles is not "PDF") then
error "PDF or InDesign documents only, please."
end if
end repeat
end tell
end open
also tried.
if ((kind of item of theFiles) as string) is not “Adobe PDF document” then…
thanks for any help!!
you need to reference the numbers of thefiles like so
on open theFiles
tell application "Finder"
repeat with i from 1 to count theFiles
if (file type of item 1 of theFiles is not "IDp4") or (file type of item 1 of theFiles is not "PDF") then
display dialog "PDF or InDesign documents only, please."
end if
end repeat
end tell
end open
Hi,
an additional solution without the Finder
on open theFiles
repeat with i in theFiles
set t to file type of (info for i)
if t is not "IDp4" or t is not "PDF" then
display dialog "PDF or InDesign documents only, please."
end if
end repeat
end open
Neither option is working for me. The dialog still pops up as if the file is being read as neither IDd4 or PDF, which makes me think the script isn’t reading the file info at all. Ideas?
Are you sure that the file type is really IDp4?
Some of my InDesign CS(2) files have “IDd3”
PS: James and I changed the boolean condition to or, change it back to and,
I have “filesheck” script that read the file types so I can check that I’m referring to the correct ones. So I know that’s right. It seems that it’s when I use the boolean argument that my script doesn’t work. Your fix (the script with the “t” variable) works but it won’t read if a file is PDF. So it seems only the first half of the if/then statement is being applied.
All of this is for a script that requires PDFs or InDesign (CS2) docs then continues on. I need the script to show an error dialog if it reads that a doc doesn’t match that. So I’m testing out mini scripts to start with.
Figured it out. File types must be 4 characters long and my “PDF” was lacking the ever important space after the “F”.
It works now, thanks!!