【问题标题】:Applescript find any text from list in indesign documentApplescript 从 indesign 文档中的列表中查找任何文本
【发布时间】:2016-08-21 22:21:41
【问题描述】:

我一直在关注 Adob​​e InDesign CS6 AppleScript 脚本指南,我正在尝试更改我设置的文本。

目前它可以工作,但它只会将确切的字符串“Apple”更改为“Pear”

是否可以将 findword 设置为“apple”、“fruit”等字符串列表。 我尝试将其列为列表,但出现此错误 “设置属性“查找内容”的值无效。预期字符串或无,

另外,当它更改文本时,我想完全清除 indesign 文本框并将其替换为 changeWord

现在,如果在“Apple”之后出现任何内容,例如 Apple123,它会将其更改为“Pear123”。我需要它来清除文本框并将 changeWord 放在文本框中

任何建议将不胜感激,或者只是指向正确的方向。

谢谢!

set findWord to "Apple"
--establish text for change
set changeWord to "Pear"


tell application "Finder" to set indesignFiles to (files of folder "test1" whose name extension is "indd") as alias list



tell application "Adobe InDesign CC 2015"
     open indesignFiles


    --Clear find text preferences
    set find text preferences to nothing
    --Clear change text preferences
    set change text preferences to nothing
    --establish properties for find
    set find what of find text preferences to findWord
    --establish properties for change
    set change to of change text preferences to changeWord
    --perform change text operation
    tell document 1
    change text
end tell
    set find text preferences to nothing
    set change text preferences to nothing

    if modified of active document is true then
        tell active document to save
    end if


    tell active document
        export format PDF type to "Macintosh HD:Users:mattsocha:Desktop:Test1:test.pdf" without showing options
    end tell

end tell 

【问题讨论】:

    标签: list applescript adobe-indesign finder


    【解决方案1】:

    您可以使用正则表达式,这将替换以列表中的一项开头的任何单词。

    set findWord to "(apple|pear|peach|banana)\\w*"
    set changeWord to "fruit"
    
    tell application "Adobe InDesign CC 2015"
    
    set find grep preferences to nothing
    set change grep preferences to nothing
    
    set find what of find grep preferences to findWord
    set change to of change grep preferences to changeWord
    
    
    tell document 1
        change grep
    end tell
    
    set find grep preferences to nothing
    set change grep preferences to nothing
    
    end tell
    

    【讨论】:

      猜你喜欢
      • 2020-09-21
      • 2016-06-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多