Copying OS X apps

J. Landman Gay jacque at hyperactivesw.com
Tue Oct 29 21:10:01 EST 2002


 > you need to use applescript (and don't forget about use
 > colon-delimited paths).

Thanks Ken, that helps a lot -- and I would have forgotten about the 
colons if you hadn't mentioned it. Just knowing I need to use 
AppleScript saved me hours. I haven't tried it in MetaCard yet, but in 
the Script Editor, copying an OS X app seems to move the whole package. 
That is, this AppleScript moves the whole application bundle intact:

tell application "Finder"
  set theSrcPath to "Macintosh HD:Users:username:folder1:test_app.app"
  set theDestPath to "Macintosh HD:Users:username:folder2"
  duplicate file theSrcPath to folder theDestPath with replacing
end tell

Apparently AppleScript/Finder in OS X is smart enough to know that a 
folder named ".app" should be treated like a file and it moves the whole 
bundle. I didn't need to worry about icons or anything in the Contents 
folder, they went over by themselves. A nice touch. I also found that if 
you know the name of the non-startup volume, you can plug it into one of 
the paths and the copy will still work. MC can get the disk names with 
the "volumes" function, so I'm in business. Now all I need to do is 
re-script it for MC with all those quote constants. ;)

Thanks again. Big help.


On 10/29/02 5:47 PM, Ken Ray wrote:
> Sorry about that...
> 
> I was saying you need to use applescript (and don't forget about use
> colon-delimited paths). Here's the code I use... note that this works only
> for the boot volume and not for other volumes (because non-boot volumes
> start with "/Volumes/<volName>/"):
> 
> 
> function CopyApp pSrcPath,pCopyName
>   -- Assumes pSrcPath is "/" delimited
>   put "" into tNewApp
>   if last char of pSrcPath is "/" then delete last char of pSrcPath
>   put pSrcPath into tASPath
>   replace "/" with ":" in tASPath
>   if first char of tASPath is ":" then delete first char of tASPath
>   put "tell application" && q("Finder") & cr into tAS
>   put "duplicate file" && q(tASPath) && \
>     "of startup disk replacing existing items"  & cr after tAS
>   put "set the name of the result to" && q(pCopyName) & \
>     cr & "end tell" after tAS
>   do tAS as AppleScript
> end CopyApp
> 
> function q what
>   return quote & what & quote
> end q
> 
> Hope this helps... don't forget that if you copy an app in OS X, you still
> will need to deal with bundle information, icons, etc. for the new copy.
> 
> Ken Ray
> Sons of Thunder Software
> Email: kray at sonsothunder.com
> Web Site: http://www.sonsothunder.com/


-- 
Jacqueline Landman Gay         |     jacque at hyperactivesw.com
HyperActive Software           |     http://www.hyperactivesw.com




More information about the metacard mailing list