• 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: Read an alias file from AppleScript
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Read an alias file from AppleScript


  • Subject: Re: Read an alias file from AppleScript
  • From: Yvan KOENIG <email@hidden>
  • Date: Fri, 22 Apr 2005 10:22:23 +0200


Le 22 avr. 2005 , à 3:49, Neil Faiman a écrit :

Should 'read file "foo"' work when foo is an alias file to a text file? I could swear that this used to work (famous last words), but when I try it now, I get "End of file error". (If I open "foo" in BBEdit, I get the text file that it is an alias to, as I would expect.)

Hello

This script grab the parent file of an alias one.

This will allow you to open an read this file.

--[SCRIPT Récupère Original d'un alias]
(*
-- +-+-+-+-+-+
Exécuter ce script ou déposer l'icône d'un fichier
sur son icône (version application)

Yvan KOENIG le 22 avril 2005
-- +-+-+-+-+-+
*)
property french : true (* true = messages français
false = english messages *)

property msg99 : "" -- globale

------------------------------------------------------------------------ -----------

-- deux lignes exécutées si on double clique l'icône du script

if french is true then
	set msg0 to "Choisir un fichier …"
else
	set msg0 to "Choose a file …"
end if

choose file with prompt msg0
open (result as list)

on open sel -- sel contient une liste d'alias des éléments
	-- qu'on a déposés sur l'icône du script (la sélection)
	if msg99 is "" then my prepareMessages()
	TraiteLeFichier(item 1 in sel)
end open -- fin 2

on TraiteLeFichier(zefile)
try
tell application "Finder"
if kind of zefile is "Alias" then set zefile to (original item of zefile) as alias
end tell

on error MsgErr number NroErr
if NroErr is not -128 then
beep 2
tell application (path to frontmost application as string) to ¬
display dialog "" & NroErr & " : " & MsgErr with icon 0 ¬
buttons {msg99} giving up after 20
end if
set AppleScript's text item delimiters to ""
return
end try
end TraiteLeFichier


on dialogue(m, l, n)
	set ll to l as list (* par sécurité *)
	tell application (path to frontmost application as string)
		set choix to button returned of ¬
			(display dialog m buttons ll default button n)
		set monChoix to choix as text
	end tell -- application
end dialogue

on prepareMessages()
	if french is true then
		set msg99 to " Vu "
	else
		set msg99 to "Oops"
	end if
end prepareMessages

--[/SCRIPT]

Yvan KOENIG

_______________________________________________
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


References: 
 >Read an alias file from AppleScript (From: Neil Faiman <email@hidden>)

  • Prev by Date: 10.3.9 Broke something
  • Next by Date: apple script error
  • Previous by thread: Read an alias file from AppleScript
  • Next by thread: 10.3.9 Broke something
  • Index(es):
    • Date
    • Thread