• 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: Alias Files
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Alias Files


  • Subject: Re: Alias Files
  • From: "Steven D. Majewski" <email@hidden>
  • Date: Thu, 13 Sep 2007 13:19:42 -0400


On Sep 13, 2007, at 11:40 AM, Mark J. Reed wrote:

I'm confused by the question.  An alias only aliases the target, not
the target's location.  I fail to see how removing the alias can have
any effect whatsover on the target.


I think the original question was about identifying which one was the symbolic link or alias.


But there are some cases where there's a magic dereferencing going on
that you might have to watch out for.


set ppath to "/Users/sdm7g/E" POSIX file ppath

where E is a symbolic link to echo.sh, returns a reference to the linked to file:

	file "sdm7g-Main:Users:sdm7g:echo.sh"

However, if you avoid the posix path, 'info for' on a symbolic link
says it's an Alias:


kind of (info for file "sdm7g-Main:Users:sdm7g:E") --> "Alias"


[ Same thing that's returned for a MacOS Alias.
So how can you tell an Mac Alias apart from a unix symbolic link in applescript ? ]



From the shell, there are several other ways to identify a symbolic link.


'file' and 'ls -l' or 'ls -F' were already mentioned:

	$ file E
	E: symbolic link to `echo.sh'


$ ls -l E lrwxr-xr-x 1 sdm7g sdm7g 7 Jun 13 13:28 E -> echo.sh


$ ls -F E E@


You can use 'find' to find all files of type l ( l = symbolic link )
( and if you want to delete them with the same command, add '-delete' to the command. )


	$ find . -maxdepth 1 -type l -print
	./E

You can test if it's a link before doing some operation in the shell:

	$ if [ -L E ] ; then echo E ; fi
	E


And you can get the linked-to file path with readlink:

	$ readlink E
	echo.sh

readlink of a non link returns nothing, so a non empty string can also
identify a link file.

	$ readlink echo.sh
	$


-- Steve Majewski

_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden
References: 
 >Re: Alias Files (From: "Gary (Lists)" <email@hidden>)
 >Re: Alias Files (From: "Mark J. Reed" <email@hidden>)

  • Prev by Date: Re: fileMaker Value Lists
  • Next by Date: Re: Alias Files
  • Previous by thread: Re: Alias Files
  • Next by thread: Re: Alias Files
  • Index(es):
    • Date
    • Thread