You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何用AppleScript实现文件复制、按午夜秒数重命名后用InDesign打开

完整实现代码
-- 请将下方路径替换为你实际的.indd源文件路径
set sourceFilePath to "Macintosh HD:Users:user:Documents:filename.indd"

-- 计算从今日午夜到当前时间的总秒数
set currentTime to current date
set secondsSinceMidnight to (time of currentTime) as string

-- 生成新文件名
set newFileName to secondsSinceMidnight & ".indd"

tell application "Finder"
    -- 复制文件到源文件所在目录,并重命名
    set duplicatedFile to duplicate file sourceFilePath
    set name of duplicatedFile to newFileName
    -- 获取新文件的完整路径
    set newFilePath to POSIX path of (duplicatedFile as alias)
end tell

-- 使用Adobe InDesign 2020打开新生成的副本
tell application "Adobe InDesign 2020"
    open POSIX file newFilePath
    activate
end tell
注意事项
  • 运行前请将sourceFilePath变量的值替换为你自己的源.indd文件的实际路径
  • 若你使用的InDesign版本名称和示例不一致,请修改最后tell application后的应用名称为你本地的实际应用名
  • 极低概率下如果同一秒内多次运行脚本会出现重名冲突,Finder会自动在文件名后加副本后缀,不会覆盖原有文件
  • 如果需要将副本存放到其他指定目录,可以在duplicate命令后加to folder "目标文件夹路径"参数

内容的提问来源于stack exchange,提问作者user1207524

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.09.27 01:24:03