Applescript旁路提示

时间:2015-02-23 11:50:36

标签: automation applescript prompt repeat adobe-indesign

我正试图绕过提示。这是一段“我的”代码:

tell application "Finder"
    set folderA4 to choose folder with prompt "Please select the Folder with A4-booklets"
    set allFiles to every file of folderA4
    set listCount to count every item of allFiles
end tell
tell application "Adobe InDesign CS6"
    repeat with i from 1 to listCount
        set myDocument to make document
        set myPDF to choose file
        ...

稍后我需要将此文件放在InDesign中:

tell myPage
    set myPDFPage to place myPDF    
    set myPDFPage to item 1 of myPDFPag
end tell

但我不想手动选择文件,而是以这种方式自动选择:

tell application "Adobe InDesign CS6"
    repeat with i from 1 to listCount
        set myDocument to make document
        set myPDF to item i of folderA4

这样就可以自动选择folderA4的所有pdf文件......

然而,这会导致错误,指出无法请求第1项的别名。 (编号-1728)

我做错了什么?

提前致谢!

3 个答案:

答案 0 :(得分:0)

试试这个,它应该给你一个文件夹中的pdf文件列表:

tell application "Finder"
    set folderA4 to choose folder with prompt "Please select the Folder with A4-booklets"
    set allFiles to every file of folderA4
    set listCount to count every item of allFiles
    set pdfFiles to {}
    repeat with i from 1 to listCount
        tell application "Finder" to set {fType, nExt} to ({file type, name extension} of item i of allFiles)
        if (fType is "PDF ") or (nExt is "pdf") then
            set pdfFiles to pdfFiles & {item i}     
        end if
    end repeat
end tell

这是基于jweaks之前的回答:

Applescript to (if/then) determine file type and choose correct program to open and print file (within batch sequence)

答案 1 :(得分:0)

答案是:

set myPDF to item 1 of allFiles as alias

这就是全部!

答案 2 :(得分:0)

如果我像这样使用它,这对我来说很好:

tell application "Finder"
    repeat with i from 1 to listCount
        set myPDF to item i of folderA4

tell application "Adobe InDesign CS6"
    repeat with i from 1 to listCount
        set myDocument to make document

我认为混合查找器和InDesign功能在这种情况下不起作用。尝试在循环中调用Finder:

repeat with i from 1 to listCount
  tell application "Adobe InDesign CS6"
    set myDocument to make document
  tell application "Finder"
    set myPDF to item i of folderA4