Applescript从资源中复制文件,与Finder交互,捕获一个Pro

Applescript从资源中复制文件,与Finder交互,捕获一个Pro,applescript,Applescript,我有一个Applescript应用程序,它将一个特定的.txt文件和一个空白的Capture One Pro.session从应用程序包资源复制到用户选择的新名称和位置,然后将Capture One(id C1PR)打开 脚本正在运行,但我对编码还是有点陌生,所以我希望有更好/更整洁的方法来编写它。 具体来说,如果4个单独的显示对话框和选择文件夹可以替换为2个“选择文件名并提示”s 我还没有弄清楚如何使用选择文件名提示,然后创建该文件夹,同时保留名称输入以生成“newJobName”或“sesh

我有一个Applescript应用程序,它将一个特定的.txt文件和一个空白的Capture One Pro.session从应用程序包资源复制到用户选择的新名称和位置,然后将Capture One(id C1PR)打开

脚本正在运行,但我对编码还是有点陌生,所以我希望有更好/更整洁的方法来编写它。 具体来说,如果4个单独的显示对话框和选择文件夹可以替换为2个“选择文件名并提示”s

我还没有弄清楚如何使用选择文件名提示,然后创建该文件夹,同时保留名称输入以生成“newJobName”或“seshName”变量供以后使用

如果您有任何关于清理此问题的建议,以及关于使用用户输入脚本添加中的“选择文件名”提示的提示,我将不胜感激。谢谢

这是当前的脚本

set logoIcon to alias ((path to me as string) & "Contents:Resources:Ourlogo.icns")
set bundleResources to (path to me as string) & "Contents:Resources:"
set defaultLocation to (path to desktop) as alias
set newJobname to text returned of (display dialog "TODAY'S JOB NAME:" with title "OurCompany New Job" default answer "Job-2018-00-00" with icon logoIcon)
set newLoc to (choose folder with prompt "CHOOSE SAVE LOCATION FOR TODAY'S JOB:" default location defaultLocation)

tell application "Finder"
    set newJobDirectory to make new folder at newLoc with properties {name:newJobname}
    set getJobBrief to file "job_brief_template.rtf" of (bundleResources as alias) --getting job brief from bundle and renaming to match today's job after duplicating
    duplicate getJobBrief to newJobDirectory
    set name of document file "job_brief_template.rtf" of newJobDirectory to newJobname & ".rtf"
    make new folder at newJobDirectory with properties {name:"Raw Folder"} --creating standard folders required for our daily jobs
    make new folder at newJobDirectory with properties {name:"Mark Ups"}
    make new folder at newJobDirectory with properties {name:"Resources"}
    make new folder at newJobDirectory with properties {name:"JPGS"}
    make new folder at newJobDirectory with properties {name:"No Retouching"}

    set seshName to text returned of (display dialog "TODAY'S CAPTURE SESSION NAME:" default answer newJobname with icon logoIcon) --usually the same as the newJobName but need to give user a choice to ammend it.
    set the clipboard to {text:seshName, Unicode text:seshName} --setting job name to clipboard in case Capture Session doesn't work.

    set targetSesh to (choose folder with prompt "CHOOSE LOCATION FOR TODAY'S CAPTURE SESSION:" default location defaultLocation)
    set newSeshDirectory to make new folder at targetSesh with properties {name:seshName}
    make new folder at newSeshDirectory with properties {name:"Capture"} --creating standard Capture One Pro session folders
    make new folder at newSeshDirectory with properties {name:"Selects"}
    make new folder at newSeshDirectory with properties {name:"Output"}
    make new folder at newSeshDirectory with properties {name:"Trash"}
    set getSeshDoc to file "session.cosessiondb" of (bundleResources as alias) --getting blank session from bundle and renaming to match today's job after duplicating
    duplicate getSeshDoc to newSeshDirectory
    set name of document file "session.cosessiondb" of newSeshDirectory to seshName & ".cosessiondb"
    set openSesh to result --variable to tell Capture One application to open

end tell

选择文件名
返回一个
文件
说明符(文件URL),该说明符可以轻松转换为POSIX路径

这是一个清理版本,它使用shell命令
mkdir
在一行中创建所有文件夹

set bundleResources to (path to me as string) & "Contents:Resources:"
set defaultLocation to path to desktop
set newJobLocation to (choose file name with prompt "TODAY'S JOB NAME:" default name "Job-2018-00-00" default location defaultLocation) as text

do shell script "/bin/mkdir -p " & quoted form of POSIX path of newJobLocation & "/{'Raw Folder','Mark Ups',Resources,JPGS,'No Retouching'}"
tell application "Finder"
    set jobName to name of folder newJobLocation
    set getJobBrief to file "job_brief_template.rtf" of folder bundleResources
    duplicate getJobBrief to folder newJobLocation
end tell

set newSeshLocation to (choose file name with prompt "TODAY'S CAPTURE SESSION NAME:" default name "Job-2018-00-00" default location defaultLocation) as text
do shell script "/bin/mkdir -p " & quoted form of POSIX path of newSeshLocation & "/{Capture,Selects,Output,Trash}"
tell application "Finder"
    set seshName to name of folder newSeshLocation
    set getSeshDoc to file "session.cosessiondb" of folder bundleResources
    set duplicatedFile to duplicate getSeshDoc to folder newSeshLocation
    set name of duplicatedFile to seshName & ".cosessiondb"
    set the clipboard to {text:seshName, Unicode text:seshName}
end tell
set openSesh to result --variable to tell Capture One application to open

非常感谢你!这更整洁!但是,我在第6行的“将jobName设置为文件夹名称”部分遇到了-1728错误。特别是“名字”这个词。无效的对象引用。有什么建议吗?再次感谢!