Re: Aliases and Assimilator
Re: Aliases and Assimilator
- Subject: Re: Aliases and Assimilator
- From: Richard 23 <email@hidden>
- Date: Tue, 28 Nov 2000 13:38:58 -0800
>
After copying a disk to my server, I need to "fix the aliases" so they
>
point to the original file on the image, rather than the original computer
>
(through the network).
>
I think I can identify all files in a folder which are aliases. Something
>
like "set alias_list to every file in folder "Disk Image" whose alias
>
property is true" I know it's not 100% correct, but I think that's close.
>
But what do I do then?
>
>
Basically, what I need to do is 1) identify all alias files, 2) discern
>
where the original file is on the local disk image and 3) re-create an
>
alias from the true original to the current location of the existing alias.
>
>
Can some one help me with step 2?
I can help you with step 7.
Then five more and you're on your way to a lifelong journey of recovery.
By the way, the ==> is used in place of the continuation character
generated with a little thing called option-return.
--
------------------------------------------------------------------------
-- MoveEmOut (c) 2000 by Richard 23
-- free for David Bell to use once he sends me a substantial donation!
8)
--
-----------------------------------------------------------------------
-- this assumes you're copying a folder of items from one volume to
-- another, it then uses the path it's copied to as the root path
-- to substitute in all copied aliases to locate the new originals.
-- a little more complex than I had first suspected!
--
------------------------------------------------------------------------
set sourcePath to "Macintosh HD:source:"
set destPath to "Private:dest:"
MoveEmOut(sourcePath, destPath)
on MoveEmOut(remotePath, localPath)
set remotePath to remotePath as string
set thePos to (result's length) + 1
set localPath to localPath as string
tell application "Finder"
move folder remotePath to folder localPath
set rootPath to result as alias as string
set theRef to a reference to alias files ==>
of entire contents of folder localPath
if exists result then
tell theRef to set {origList, theList} to ==>
{my AliasList(original item), my AliasList(it)}
set {AppleScript's text item delimiters} to {":"}
repeat with theIdx from 1 to theList's length
set aliasPath to theList's item theIdx as string
tell result to if it ends with ":" then ==>
set aliasPath to text 1 thru -2
tell aliasPath to set {folderPath, fileName} to |->
{text items 1 thru -2 & {""} as string, last text
item}
delete theList's item theIdx
text thePos thru -1 of (origList's item theIdx as string)
set newPath to rootPath & result
make alias at folder folderPath to item newPath ==>
with properties {name:fileName, label index:2}
end repeat
end if
end tell
end MoveEmOut
on AliasList(theRef)
tell application "Finder" to try
theRef as alias list
on error
theRef as alias as list
end try
end AliasList
That should get you started. You might also want to take a look at
my UpdateAlias script over at the One Step Beyond site where edgy
scripting is the norm, where bell curves and bell bottoms are equally
disdained.
http://homepage.mac.com/richard23/
I believe you'll find UpdateAlias on page 2 with the other Finder scripts.
Happy trails,
R23
Moment of Terror is the Beginning of Life