Applecript& acrobat pro:文档不了解插入页面消息

时间:2013-09-27 08:58:57

标签: applescript acrobat

这是我的脚本,我不断收到这个错误 - 我一整天都在努力,但似乎没有让它工作。 事情就是这样:我在这里运行2个案例,每次我删除其中一个(只插入一个文档)它运行正常。所以代码不能错。我之前用两个ifs让它工作但不知何故我被卡住了我需要插入的真实pdf文件。什么是错的? 我已经复制了我在2007年发布的一篇文章中的部分脚本,但它没有解决问题。

set mainfolder to choose folder
tell application "Finder" to set folderList to (sort folders of mainfolder as alias list by name)
display dialog "Ordner docs wählen"
set source_folder to choose folder

repeat with i from 1 to count of folderList
   try
       tell application "Finder" to set Master_File to (files of entire contents of (item i of folderList))
   end try


   repeat with i from 1 to count of folderList
     try
        tell application "Finder" to set Master_File to (files of entire contents of (item i of folderList))
     end try


   tell application "Finder" to set file_list to (files of entire contents of source_folder)

   tell application "Adobe Acrobat Pro"
       open Master_File
       set Master_Doc to document 1
       set PageCount to 0
   end tell

   repeat with this_file in file_list

       tell application "Adobe Acrobat Pro"
           if name of this_file is "xxx.pdf" then
              open (this_file as alias)
              insert pages Master_Doc after PageCount from document 2 starting with 1 number of pages 1
              close document 2 without saving
           end if

           if name of this_file is "yyy.pdf" then
              open (this_file as alias)
              set PageCount to 2
              insert pages Master_Doc after PageCount from document 2 starting with 1 number of pages 5

              close document 2 without saving
           end if

        end tell
    end repeat

 tell application "Adobe Acrobat Pro"
 close Master_Doc saving yes
 end tell

 end repeat

非常感谢帮助!谢谢你们

1 个答案:

答案 0 :(得分:0)

我不确定这是不是你想要做的,但我想我明白了。

在你的帖子中你在嵌套循环中使用相同的i变量,你应该总是在你的嵌套循环时使用一个新变量,否则你会遇到问题

set mainfolder to choose folder
set source_folder to choose folder
tell application "Finder"
    set folderList to (sort folders of mainfolder as alias list by name)

    repeat with afolder in folderList
        set afolder to afolder as alias
        set Master_File to (first file of folder afolder)
        tell application "Adobe Acrobat Pro"
            open Master_File
            set Master_Doc to document 1
            set PageCount to 0
        end tell

        set file_list to (files of entire contents of source_folder)
        repeat with this_file in file_list

            tell application "Adobe Acrobat Pro"
                if name of this_file is "xxx.pdf" then
                    open (this_file as alias)
                    insert pages Master_Doc after PageCount from document 2 starting with 1 number of pages 1
                    close document 2 without saving
                end if

                if name of this_file is "yyy.pdf" then
                    open (this_file as alias)
                    set PageCount to 2
                    insert pages Master_Doc after PageCount from document 2 starting with 1 number of pages 5

                    close document 2 without saving
                end if

            end tell
        end repeat

    end repeat
    tell application "Adobe Acrobat Pro" to close Master_Doc saving yes
end tell