Applescript一个可在多个桌面上使用的Variable文件夹位置

时间:2014-06-24 19:19:09

标签: pdf applescript acrobat

(我是一个真正的新手)我能够通过剔除其他帖子中的位来创建一个苹果脚本。此脚本使用acrobat pro 11引擎从文件夹批量打印PDFS,并在完成时将它们移动到单独的文件夹中...虽然脚本在修复桌面路径的一台计算机上运行良好。必须针对我们使用的每台计算机修改它。有没有办法在可变位置编写监视文件夹的脚本?

property myFolder : "HD:Users:User:desktop:Print:"

set myfiles to list folder myFolder without invisibles

repeat with myfile in myfiles

    set mycurrentfile to ((myFolder as string) & (myfile as string)) as string
    batchprint(mycurrentfile)

end repeat

on batchprint(mycurrentfile)

    tell application "Adobe Acrobat Pro"
        activate -- bring up acrobat
        open alias mycurrentfile -- acrobat opens that new file    
        tell application "System Events"
            tell process "Acrobat"
                click menu item "Print..." of menu 1 of menu bar item "File" of menu bar 1
                click button "Print" of window "Print"
                tell application "System Events"
                    tell process "Acrobat"
                        click menu item "Close" of menu 1 of menu bar item "File" of menu bar 1
                    end tell
                end tell
            end tell
        end tell
    end tell

    tell application "Finder" -- to move the printed file out 
        set x to (("HD:Users:User:desktop:Printed PDFs") as text)
        if alias x exists then
            beep
        else
            make new folder at the desktop with properties {name:"Printed PDFs"}
        end if
        move alias mycurrentfile to folder "Printed PDFs"
end tell


end batchprint

1 个答案:

答案 0 :(得分:0)

在AppleScript中,您可以使用path to Desktop Folder来引用当前用户的桌面文件夹 E.g:

set myFolder to (path to Desktop Folder as text) & "Print:"