2015-02-23 84 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