2015-02-23 51 views
0

我试图绕过提示。这是一块“我”的代码:Applescript旁路提示

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)

我在做什么错?

提前致谢!

回答

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)

+0

该文件夹只包含pdf文件,所以并没有真正改变这种情况我试过了,它没有工作。感谢您的努力! – Mauritz 2015-02-23 16:28:35

0

答案是:

set myPDF to item 1 of allFiles as alias 

就是这样!

+0

好的,我很高兴你能解决这个问题,但是当我从原始问题中尝试你的代码片段时,他们工作得很好,没有别名错误。我怀疑这个错误是在你的代码中稍后出现的,你需要一个别名。正如我所提到的那样,这个问题还不清楚,你的评论没有帮助 – 2015-02-23 17:08:14

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