• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Kind of HTML files
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Kind of HTML files


  • Subject: Re: Kind of HTML files
  • From: Yvan KOENIG <email@hidden>
  • Date: Wed, 18 Oct 2006 21:18:31 +0200


Le 18 oct. 2006 à 19:13, Christopher Nebel a écrit :

On Oct 18, 2006, at 7:56 AM, Yvan KOENIG wrote:


The kind property in Finder's item class contains a localised description. If you're on 10.4, use System Events or Standard Additions to check the file's uniform type identifer, e.g.:


tell application "System Events"
get every file of someFolder whose type identifier is "public.html"
end


For more info on UTIs, see <http://developer.apple.com/macosx/ uniformtypeidentifiers.html> and the follow the links at the bottom of the page.

If you're not on 10.4, I think you'll need to make up a list of all possible name extensions and test against that.

I assumes that what I will write now is mainly to Chris Nebel's attention.

Just as long as you don't start referring to me as "he-who-shall- not-be-named" in order to *not* attract my attention.


Would it be difficult to add type identifier to the properties treated by the Finder so it would be easier to deal with this "modern identifier" without localization oddities? With such a formula, the localized kind would be available when localisation is required and the universal type identifier would be available when needed.

Is there any reason you want this in Finder specifically? Would adding the localized kind to System Events work just as well?


Yes I have.

I explained the "problem" in a recent message.

I reproduce it here (with some corrections):


Hello

For info, I coded this way:

 set htmlFlag to (file type of element is "html") or ¬
 (name extension of element is in {"html", "htm"}) or ¬
 (type identifier of (info for element) is "public.html") or ¬
 (kind of element is in {"Document HTML", "HTML Document"})

I just wished to get rid of the type identifier which nead to code this way .

I hoped to be able to code:

 tell application "Finder" to set listeHTML to ¬
 every file of thisFolder whose (file type  is "html") or ¬
 (name extension  is in {"html", "htm"}) or ¬
 (kind of element is in {"Document HTML", "HTML Document"})

because i feel unable to put the test upon type identifier in this late instruction.

Just after posting the message I thaught that I was able to do that with System Events but I can't do the same if I need to use "entire contents of folder myFolder".

This is why I asked for the introduction of "type identifier" in the Finder dictionnary.

Yvan KOENIG

Here is the full set of tests I made:


tell application "System Events" to set listeHTML to ¬
every file of folder "Macintosh HD:Users:yvankoenig:Desktop:dossier de départ:" whose type identifier is "public.html"
(*
{file "Macintosh HD:Users:yvankoenig:Desktop:dossier de départ:2D- Histogram.html", file "Macintosh HD:Users:yvankoenig:Desktop:dossier de départ:__builtin__.dict-class.html"}
*)


tell application "System Events" to set listeHTML to ¬
every file of folder "Macintosh HD:Users:yvankoenig:Desktop:dossier de départ:" whose kind is "HTML Document"


(* returns {}  because it's localized *)

tell application "System Events" to set listeHTML to ¬
every file of folder "Macintosh HD:Users:yvankoenig:Desktop:dossier de départ:" whose kind is "Document HTML"
(*
returns
{file "Macintosh HD:Users:yvankoenig:Desktop:dossier de départ:2D- Histogram.html", file "Macintosh HD:Users:yvankoenig:Desktop:dossier de départ:__builtin__.dict-class.html"}
*)


(*
tell application "System Events" to set listeHTML to ¬
every file of folder "Macintosh HD:Users:yvankoenig:Desktop:dossier de départ:" whose kind is in {"Document HTML", "HTML Document"}
*)
(*
errors with:
get every file of folder "Macintosh HD:Users:yvankoenig:Desktop:dossier de départ:" whose {"Document HTML", "HTML Document"} contains kind
"Erreur dans System Events : Impossible de transformer every file of folder \"Macintosh HD:Users:yvankoenig:Desktop:dossier de départ: \" whose {\"Document HTML\", \"HTML Document\"} contains kind en type reference."


		*)

tell application "System Events" to set listeHTML to ¬
every file of folder "Macintosh HD:Users:yvankoenig:Desktop:dossier de départ:" whose name extension is "html"
(*
{file "Macintosh HD:Users:yvankoenig:Desktop:dossier de départ:002- Sets.html", file "Macintosh HD:Users:yvankoenig:Desktop:dossier de départ:2D-Histogram.html", file "Macintosh HD:Users:yvankoenig:Desktop:dossier de départ:__builtin__.dict- class.html"}
*)


(*
tell application "System Events" to set listeHTML to ¬
every file of folder "Macintosh HD:Users:yvankoenig:Desktop:dossier de départ:" whose name extension is in {"html", "htm"}
*)
(* errors with:
get every file of folder "Macintosh HD:Users:yvankoenig:Desktop:dossier de départ:" whose {"html", "htm"} contains name extension
"Erreur dans System Events : Impossible de transformer every file of folder \"Macintosh HD:Users:yvankoenig:Desktop:dossier de départ: \" whose {\"html\", \"htm\"} contains name extension en type reference."
*)





_______________________________________________ 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
  • Prev by Date: newbe - Making iTunes Browser Window active
  • Next by Date: Re: Move files to the right folder.
  • Previous by thread: Re: Kind of HTML files
  • Next by thread: Rép: Kind of HTML files
  • Index(es):
    • Date
    • Thread