Comparing variable types

Hi,

I am trying to modify an apple script that gets the file type of a file and then assigns an extension. The problem that I am having is trying to determine when the file has no type.
The script I was using is:


set {fileType, creatorType} to {file type, file creator} of (get info for itemAlias)
if creatorType is "" then -- perform function

I think I must be comparing the variable “creatorType” to the wrong type, but still learning :wink:
Any information would be very helpful

Thanks.

The file creator is never “empty”. Try selecting a file with no file creator and run:

set itemAlias to choose file
set creatorlength to {length of file creator} of (get info for itemAlias)

You’ll see it returns a value of 4“ four empty characters.

I only know how to use ASCII characters to represent empty characters, using ASCII character 0 , as a typed space is ASCII character 32.

So try changing:

if creatorType is "" then

to:

if creatorType is ((ASCII character 0) & (ASCII character 0) & (ASCII character 0) & (ASCII character 0)) then

-N

Rather than mucking with detection of ascii characters, just coerce the value to unicode and then your existing code will work fine…

set {fileType, creatorType} to {file type, file creator} of (get info for itemAlias)
set creatorType to (creatorType as Unicode text)

if creatorType is "" then
	return "Empty String"
else
	return creatorType
end if

j

Thanks for your help, that’s allowed me to move the main problem of assigning extensions to files without creator types using the magic type. It would been alot easier is people just stayed on a Mac instead of Mac to PC to Mac :wink:

Thanks again :slight_smile: