tags:

views:

168

answers:

5

Hey guys,

I want to put an alias to a fixed folder, namely the iWorks template folder into a DMG.

The directory is

/Users/USERNAME/Library/Application Support/iWork/Pages/Templates/My Templates

My Problem is, that I want to put it into a DMG so people can easily install the template. But while it works fine with the Application folder, the template folder always has my username in it. So if someone else opens it, the alias points to the dir with my username, which of course does not exist on a different mac.

Does anyone have any idea how to fix it?

Thanks.

+2  A: 

The ~ folder represents the users home directory. So your folder would be ~/Library/Application Support/iWork/Pages/Templates/My Templates.
In response to your comment: I am not sure if this is possible. You could try ln from Terminal. It is a utility for making links. But I think it just converts ~ to the actual path of your home directory when you use it. And I think you would have to make a symbolic link as apposed to a hard link, which some file systems might not support (All macs should though). Another possibility would be to make a simple Applescript droplet that uses a shell script to move the file you drag onto it to the path you want. Paste the following code into script editor and save it as an Application or Application Bundle (doesn't matter which):

on open thefile
 do shell script "mv " & POSIX path of thefile & " ~/Library/Application\ Support/iWork/Pages/Templates/My\ Templates/"
end open

When you drag a file to the application you made it will move it to your directory. You could change the icon by right clicking on the app and selecting "Get Info", then pasting the new icon on top of the old one, to make it look more like a folder.

None
Okey,so apparently, thanks to your input I figured out, that it seems to be`~/Library/Application\ Support/iWork/Pages/Templates/My\ Templates/`at least in Terminal that is. How do I now get a folder/alias to represent this link? Thanks for your help.
Lukas Oppermann
I edited my answer to show you possible solutions.
None
+1  A: 

You can use this applescript. Save it as an application and include it on your install disk. All a user would have to do is run the applescript application to install the alias... or you can run it automatically from your own code after you place your application on the user's drive. Just fix the inputFile variable to point to your file. In this example, I just grabbed an image from inside the Address Book.app application.

set inputFile to (path to applications folder as text) & "Address Book.app:Contents:Resources:AB16.png"

-- first create the outputFolder if necessary
set outputFolder to (path to application support folder from user domain as text) & "iWork:Pages:Templates:My Templates:"
do shell script "/bin/mkdir -p " & quoted form of POSIX path of outputFolder

-- create the alias in the outputFolder
tell application "Finder"
    make new alias file at folder outputFolder to file inputFile
end tell
regulus6633
A: 

Combining all of your comments to the following I get a droplet working the way I want.

on open thefiles    
    set outputFolder to (path to application support folder from user domain as text) & "iWork:Pages:Templates:My Templates:"
    do shell script "/bin/mkdir -p " & quoted form of POSIX path of outputFolder
    tell application "Finder"
        duplicate thefiles to outputFolder
    end tell    
end open

The Problem is, while it works on my mac, I can not use it being inside the DMG file. I can not Drag anything on it. Any ideas?

Thanks so far.

Lukas Oppermann
Why can't you drag files onto it? If you include it in your DMG than drag the template onto it, it should move the template to the folder you want.
None
Lukas Oppermann
Your DMG worked perfectly on my mac. It mounted automatically and when I dragged the template to the droplet it installed.
None
Really? Damn, thats good news, now I just have to figure out why it does not work with me. Maybe some security settings?
Lukas Oppermann
I just ran it on another mac an it works just fine. I do have snow leopard though and the other mac had leopard. Any ideas what I can do? The people who will get this DMG have snow leopard too.
Lukas Oppermann
A: 

Hi Lukas,

just wondering if you ever resolved this problem as I have the same issue,

thanks, Rebecca

Rebecca
Yes I did using the installer idea. With an Installer it works just fine. But maybe with mouviciel oxutils it works as well?
Lukas Oppermann
+1  A: 

What you need is relative aliases.

An old package is able to create them: this osxutils.

Another solution is to create a symbolic link.

mouviciel