I’m a little confused by your post. You say at the end that when you specify a fileType (e.g., fileType IS NOT emptyString) you’re script jumps down to your “else” clause.
Unless I’m reading something wrong, that’s exactly what your script is telling it to do. It’s evaluating fileType = emptyString to false and therefore moving to the “else” clause. If this isn’t what you’re expecting, then you may want to post a more detailed explanation or what exactly you’re trying to do.
Also, instead of setting an emptyString variable, you can just use “” in your script. It’s only two keys instead of 11.
copy the result to thisfile
copy the file type of the (info for thisfile) to fileType
set emptyString to ""
if fileType = emptyString then
display dialog "I don't recognize the file extension"
display dialog fileType & " " & result
Thats it, all it does is identify file type and path.
Keep in mind that most file types have a four character type definition, i.e. a .txt file is understood by the OS to be a TEXT file, a .app file is understood to be APPL. Now if, for instance you have a .csv file, the OS has no recognizable format for this file and the fileType returned is “”, or an empty string.
Got ya. The only thing I can think of is to have another else statement catch it if there’s no file type, and try to get the file’s extension, then somehow convert that to a file type (you’ll need some kind of list of extensions and corresponding file types to do this). Presumably, any file will have either a file type or extension (or you’d have to specify an app to open it each time).
Yeah, thats where my problem ls. I cant seem to get the script to acknowledge when fileType is empty. I also tried to set it to null if it was empty but still the condition was bypassed and it dropped into the else.