首页 > 解决方案 > AppleScript - Indesign 中的重新链接文件 - 无法从给定的 URI 创建链接资源

问题描述

我正在尝试在 Automator 中创建一个文件夹操作,该操作复制特定的 .indd 文件,在 InDesign 中打开它,然后将“test1.png”与拖放到文件夹中的文件重新链接,该文件绑定到 Automator 操作。

我可以让它使用硬编码的文件路径,但如果我尝试动态获取文件路径,它会给我错误“无法从给定的 URI 创建链接资源”

这可能很简单,但我是 AppleScript 的新手,无法弄清楚。

代码:

on run {input, parameters}

tell application "Finder"
    set filename to name of file input
end tell

tell application "Adobe InDesign 2020"
    if document 1 exists then
        tell document 1
            relink link "test1.png" to "Macintosh HD" & filename
            
            try
                update link "test1.png"
            end try
            
        end tell
    end if
end tell

return input

结束运行

标签: applescriptadobe-indesignautomator

解决方案


我没有 Adob​​e InDesign 来测试这个但试试这个。

on run {input, parameters}

set theFile to input's item 1

tell application "Adobe InDesign 2020"
    if document 1 exists then
        tell document 1
            relink link "test1.png" to theFile
            try
                update link "test1.png"
            end try
        end tell
    end if
end tell

end run

推荐阅读