Copy Files to Location Other than Application Folder

I have a file that is an application add-on that I have been able to successfully package in a DropDMG DMG file with layout, license, etc. The only problem is that I can’t provide an easy way for users to be able to drag and drop the file to the necessary location for them to use it.

Originally I had created an alias and placed it in the folder of the DMG package’s contents, then placed an “icon” with the same name in the layout. When I create the DMG everything comes out perfectly in terms of appearances, except that when you click on the folder icon it does not open the correct file location. The reason being that the alias is pointing to MY user account’s Documents folder, which when provided to other users doesn’t work since they don’t have the same username. This is similar to what I saw in this forum item: http://c-command.com/forums/showthread.php/3534-symlink-alias-to-Documents-folder

After looking around online I found a similar question & answer on a different site; http://stackoverflow.com/questions/3436079/mac-create-alias-for-dmg-file-without-fixed-user-in-it/3436104#3436104

The only issue is that I have no experience with AppleScript and don’t know how to apply the idea of an automated script that would copy the file from my DMG file to the correct location. If I could get some help translating the applescript example for copying the file in my DMG to a directory in the user’s Document/destination folder that would probably help me out. The main problem being that I’m not experienced with AppleScript.

Or if there’s an alternate method that would allow users to still drag the file to a “icon” that specifies the location, I’m fine with that too but from earlier posts I’m not sure if that’s possible. Any help is appreciated. Thanks.

If your add-on is an application, I would suggest that you have the user put it in the Applications folder. Then, when launched, it could automatically copy any needed files to the proper location.

The example script doesn’t use proper quoting, and it tries to move the file. I would suggest copying it, using a droplet script like this:

on open _file
    set _sourcePath to POSIX path of _file
    do shell script "cp -r " & _sourcePath's quoted form & " ~/Documents/"
end open

Michael, I’m back and trying to do this again. I simply need to create a universal alias to the users “~/Documents/” folder. Is there a way to edit the alias I’m including with my DMG layout and corresponding files? I created an alias in Mac OS X Finder by right clicking on the location and it providing an alis but with /MYUSERNAME/Documents instead of just the universal “~/Documents” expression. Can I edit that or do you know a simple way of creating a universal alias like that?

For example, how does the “Applications” folder alias work, and is it possible to edit create a similar alias to a universal location other than Applications?

It’s a symlink rather than an alias. You can make a symlink to any absolute path. This won’t work for anything inside a user’s home folder, though, since the path would need to be different for each user.

So for example you can get to the Documents for any Mac user in the Finder by going to "Finder, Go, Enter in Go To Folder Field “~/Documents/” and press enter. This will open my Documents folder on my Mac or any other Mac (that has a “Documents” in the user folder). So I’m simply trying to create an alias to “~/Documents/”. Does that make sense?

No, that does not make sense because you cannot include the ~ character. It will get expanded by the shell right away, so you’ll end up with a link that’s hard-coded to your own home folder.

OK. No worries. It sounds like other than a package installer that can specify the users documents folder location, using an alias to any user path folder is going to be not possible. I do realize that placing the file in a non-user specific folder, is a possibility. It’s a Apple Developer Digitally Signed app distribution folder, and is going to be … (Gears turning sound effect…)

Thank you for your comment, it finally broke through and I realize what needs to be done and have setup the correct file path alias for installing my product. Sometimes the most obvious answers block us from seeing what’s right in front of our faces, causing more complications than needed (facepalm). I’m currently testing out a solution but I believe I’ve resolved the problem. Thanks!