0

这是我的脚本,我一直收到这个错误 - 我整天都在尝试,但似乎没有让它工作。事情是这样的:我在这里运行 2 个 if 案例,每次我删除其中一个(只插入一个文档)时它都可以正常工作。所以代码不可能是错误的。我之前用两个 if 让它工作,但不知何故,我被我需要插入的真正的 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

高度赞赏帮助!多谢你们

4

1 回答 1

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
于 2013-09-29T00:46:41.800 回答