Re: choose file of type
Re: choose file of type
- Subject: Re: choose file of type
- From: Paul Berkowitz <email@hidden>
- Date: Fri, 25 Nov 2005 13:21:49 -0800
- Thread-topic: choose file of type
Thanks, Bill - that's it - and a great way to find it: I didn't think of
checking in 'info for'. Nor in System Events/file, where type identifier can
also be found (but not in the Finder).
Yes, {"public.plain-text"} works for all .txt files I can find, and more.
Although .xls Excel files are found by "com.microsoft.excel.xls", you can't
get .csv files made by Excel from "com.microsoft.excel.csv" . But
"public.plain-text" _does_ pick those up too (just as file type "TEXT" does)
if the file was made by Excel Mac.
Interestingly, I have a couple of .csv and .CSV files brought over from
Excel Windows. These files show no icons, and neither "public.plain-text"
nor "com.microsoft.excel.csv" work for them in 'choose file'. But if you
double-click them, they open immediately in Excel 2004, with no preliminary
"select app" dialog. So there's still something like OS 9's File Exchange
working that knows that Excel is the default app for .csv (and CSV) but that
still doesn't register a "type identifier" for it. I wonder what the
difference is then between this connection and a true "type identifier" is.
I know that the .csv files made by Excel Mac have a "TEXT" file type, and I
imagine that that sets a "public.plain-text" type identifier. But the
Windows .csv files don't have this type identifier.
Running your script on such a file results in UTI =
--> "dyn.age80g650"
! I wonder where I got this - maybe from a user of one of my scripts. Weird.
I'll test with some files brought over directly from Excel Win in VPC soon,
and see what I get.
--
Paul Berkowitz
> From: Bill Briggs <email@hidden>
> Date: Fri, 25 Nov 2005 16:50:10 -0400
> To: AppleScript-Users <email@hidden>
> Subject: Re: choose file of type
>
> Looks like it's "public.plain-text" for text files. When I run this:
>
> tell application "Finder"
> set a_file to selection as alias
> set UTI to type identifier of (get info for a_file)
> end tell
>
> and I have a text edit file selected, that's the result. If I select an Excel
> file it's "com.microsoft.excel.xls"
>
> Looks like the UTI is tied to the extension. When I run this:
>
> choose file of type {"public.plain-text"}
>
> I can select, for example, text files with a .txt extension, but not text
> files with a .html extension.
>
> There's a table of UTIs, MIME types, and File Extensions here that's worth a
> short look.
> http://www.huw.id.au/code/fileTypeIDs.html
>
> - web
>
> At 12:14 PM -0800 11/25/05, Paul Berkowitz wrote:
>> In Tiger (maybe Panther too?), 'choose file's parameter 'of type' is now
>> described as "a list of file types or type identifiers."
>>
>> Can someone remind me what is meant by a "type identifier"? I do recall that
>> you can't mix them in with 4-char file types - it has to be one or the
>> other.
>>
>> I'm hoping that it has something to do with extensions, or even the
>> creator's identifier, so that it can work with files that don't have the old
>> style file types. For example, isn't there some way to specify .txt files as
>> made by TextEdit, which do not have "TEXT" file types?
>>
>> choose file of type {"txt"}
>>
>> or {".txt"}, or {"ttxt"}, or {"text"}, or {"com.apple.TextEdit"}, or
>> {"****"} - no .txt files created by TextEdit files are selectable in 'choose
>> file'. Is there a way? GetInfo has TextEdit set as default app for opening
>> them, if that matters.
>>
>> Ultimately, I'm also hoping to be able to specify .doc or .xls files coming
>> from Word or Excel on Windows, with no file types.
>>
>> If there isn't some way to specify extension, there should be.
>>
>> --
>> Paul Berkowitz
>>
>>
>> _______________________________________________
>> Do not post admin requests to the list. They will be ignored.
>> Applescript-users mailing list (email@hidden)
>> Help/Unsubscribe/Update your Subscription:
>>
>> This email sent to email@hidden
>
> _______________________________________________
> Do not post admin requests to the list. They will be ignored.
> Applescript-users mailing list (email@hidden)
> Help/Unsubscribe/Update your Subscription:
>
> This email sent to email@hidden
>
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden