Macos Mac为DMG文件创建别名,其中不包含固定用户

Macos Mac为DMG文件创建别名,其中不包含固定用户,macos,alias,dmg,Macos,Alias,Dmg,我想把一个别名放在一个固定的文件夹中,即iWorks模板文件夹放在一个DMG中 目录是 /Users/USERNAME/Library/Application Support/iWork/Pages/Templates/My Templates 我的问题是,我想把它放到DMG中,这样人们就可以轻松地安装模板。但是,尽管它可以与应用程序文件夹配合使用,但模板文件夹中始终包含我的用户名。因此,如果其他人打开它,别名将指向带有我的用户名的目录,当然这在其他mac上并不存在 有人知道怎么修吗 谢谢

我想把一个别名放在一个固定的文件夹中,即iWorks模板文件夹放在一个DMG中

目录是

/Users/USERNAME/Library/Application Support/iWork/Pages/Templates/My Templates
我的问题是,我想把它放到DMG中,这样人们就可以轻松地安装模板。但是,尽管它可以与应用程序文件夹配合使用,但模板文件夹中始终包含我的用户名。因此,如果其他人打开它,别名将指向带有我的用户名的目录,当然这在其他mac上并不存在

有人知道怎么修吗

谢谢


把你所有的评论和下面的结合起来,我得到了一滴我想要的东西

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
问题是,当它在我的mac上工作时,我不能在DMG文件中使用它。我不能在上面拖任何东西。有什么想法吗


非常感谢。

文件夹表示用户的主目录。因此,您的文件夹将是
~/Library/Application Support/iWork/Pages/Templates/My Templates

回应您的评论:我不确定这是否可行。您可以从终端尝试
ln
。它是制作链接的实用工具。但是我认为当你使用它时,它只是将
~
转换成你的主目录的实际路径。我认为您必须创建一个与硬链接相对应的符号链接,而某些文件系统可能不支持硬链接(尽管所有Mac都应该支持)。另一种可能是制作一个简单的Applescript液滴,它使用shell脚本将拖动到其中的文件移动到所需的路径。将以下代码粘贴到脚本编辑器中,并将其另存为应用程序或应用程序包(无论是哪个):


当您将文件拖动到您创建的应用程序时,它会将其移动到您的目录中。您可以通过右键单击应用程序并选择“获取信息”来更改图标,然后将新图标粘贴到旧图标上,使其看起来更像文件夹。

您可以使用此applescript。将其另存为应用程序,并将其包含在安装盘中。用户只需运行applescript应用程序即可安装别名。。。或者,将应用程序放在用户驱动器上后,您可以从自己的代码自动运行它。只需修复inputFile变量以指向您的文件。在本例中,我刚刚从Address Book.app应用程序中抓取了一张图像

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

您需要的是相对别名

一个旧的包可以创建它们:这个


另一个解决方案是创建一个符号链接。

好的,很明显,由于您的输入,我发现它似乎是
~/Library/Application\Support/iWork/Pages/Templates/My\Templates/
,至少在终端中是这样。现在如何获取表示此链接的文件夹/别名?谢谢你的帮助。我希望osxutils能在英特尔机器上运行!
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