我有一个Applescript应用程序,它复制一个特定的.txt文件和一个空白的捕获一个Pro .session从应用程序包资源-到用户选择的新名称和位置,然后捕获一个(id C1PR)将打开。
这个脚本正在工作,但我对编码还有点陌生,所以我希望有一种更好/更整洁的方式来编写这个脚本。具体来说,如果4x单独的'display‘和’Specifically‘可以替换为2x “选择带有提示的文件名”
我还没有想出如何使用选择文件名提示符,然后创建该文件夹,同时保留名称输入以生成"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发布于 2018-05-28 12:50:39
choose file name返回一个file说明符(文件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 openhttps://stackoverflow.com/questions/50566124
复制相似问题