Getting the type code of a file under OSX

Dave Cragg dcragg at lacscentre.co.uk
Sat Jul 30 07:07:15 EDT 2005


On 30 Jul 2005, at 10:40, Eric Chatonet wrote:

> Hi Brian,
>
> As the files function returns a list sorted by alphabetical order,  
> I don't think it's necessary.


But, for example, if you were looking for a file named "mend.png" and  
there was a file named "amend.png" in the folder, you'd find  
"amend.png".

A bit cumbersome, but when I've done this, I've repeated through all  
lines in the detailed files and done a match on the first item in each.

Cheers
dave


>
> Le 30 juil. 05 à 11:35, Brian Yennie a écrit :
>
>
>> Quick observation... you may get unreliable results when the name  
>> of one file is a substring of the name of another file in the same  
>> folder. You might try adding a comma to the file name, or using  
>> itemOffset() and wholeMatches.
>>
>> HTH
>> - Brian
>>
>>
>>
>>> Hi Howard,
>>>
>>> You could use AppleScript but doing this with Transcript is easy  
>>> and fast:
>>>
>>> function CreatorAndType pFilePath
>>>   local tDefaultFolder,tCreatorType
>>>   -----
>>>   if the platform <> "MacOs" then return "Error: filetype not  
>>> supported"
>>>   put the defaultFolder into tDefaultFolder
>>>   set the itemdel to slash
>>>   set the defaultFolder to item 1 to -2 of pFilePath
>>>   put urlDecode(the detailed files) into tFiles
>>>   put line lineOffset(item - 1 of pFilePath,tFiles) of tFiles  
>>> into tFile
>>>   set the defaultFolder to tDefaultFolder
>>>   set the itemDel to comma
>>>   put item 11 of tFile into tCreatorType
>>>   if tCreatorType = empty then return "Error: could not find the  
>>> filetype"
>>>   return char 1 to 4 of item 11 of tFile & comma & char 5 to 8 of  
>>> item -1 of tFile
>>>   -- creator and type separated by a comma
>>> end CreatorAndType
>>>
>>> Best Regards from Paris,
>>>
>>> Eric Chatonet.
>>>
>>> Le 30 juil. 05 à 01:56, Howard Bornstein a écrit :
>>>
>>>
>>>
>>>> I wanted to check to see if I'm missing something obvious. I  
>>>> want to
>>>> be able to get the type code of a specific file under OSX. As  
>>>> far as
>>>> I've been able to find, there is only one way to get the type  
>>>> code--
>>>> with the files function. The detailed files includes the type and
>>>> creator codes. However, this gets the entire list of files in the
>>>> default folder. Unless there's something I'm missing, the sequence
>>>> would be something like this:
>>>>
>>>> 1) Get the full path of the file you want the type code for
>>>> 2) Extract the folder it's in
>>>> 3) Set the default folder to that folder
>>>> 4) Get the detailed files
>>>> 5) Compare the file name with item one of every line in the files
>>>> 6) When you find a match, extract the last item from the  
>>>> detailed file
>>>> description which is the type/creator code.
>>>>
>>>> This seems like a lot of work, just to get an attribute of a  
>>>> file. We
>>>> have the filetype property, where we can set the type of a file.  
>>>> Isn't
>>>> there a simple way to *get* the type of a file?
>>>>
>>>>
>>>
>>> ----------------------------------------------------------------
>>> So Smart Software
>>>
>>> For institutions, companies and associations
>>> Built-to-order applications: management, multimedia, internet, etc.
>>> Windows, Mac OS and Linux... With the French touch
>>>
>>> Free plugins and tutorials on my website
>>> ----------------------------------------------------------------
>>> Web site        http://www.sosmartsoftware.com/
>>> Email        eric.chatonet at sosmartsoftware.com/
>>> Phone        33 (0)1 43 31 77 62
>>> Mobile        33 (0)6 20 74 50 86
>>> ----------------------------------------------------------------
>>>
>>> _______________________________________________
>>> use-revolution mailing list
>>> use-revolution at lists.runrev.com
>>> Please visit this url to subscribe, unsubscribe and manage your  
>>> subscription preferences:
>>> http://lists.runrev.com/mailman/listinfo/use-revolution
>>>
>>>
>>>
>>>
>>
>> _______________________________________________
>> use-revolution mailing list
>> use-revolution at lists.runrev.com
>> Please visit this url to subscribe, unsubscribe and manage your  
>> subscription preferences:
>> http://lists.runrev.com/mailman/listinfo/use-revolution
>>
>>
>>
>
> _______________________________________________
> use-revolution mailing list
> use-revolution at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your  
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-revolution
>




More information about the use-livecode mailing list