Applescript&;GarageSale Find&;替换选定项目上的项目

Applescript&;GarageSale Find&;替换选定项目上的项目,applescript,Applescript,我在GS中找到了这个用于搜索和查找的脚本。这是从2008年开始的,因此早期版本6可能是wirtten,而不是当前版本7。它假设在任何当前选定模板的描述中查找文本,并将其更改为用户键入的任何内容。它正确显示搜索和替换框,并且运行时没有任何错误;但是,没有更改任何文本 我尝试过出版商的论坛和文档;macscripter;还有苹果论坛。我尝试过多次修改它,但是这些更改会产生错误,阻止它运行,或者它运行但没有任何作用 我正在OS 10.13.6上使用GS 7.0.16 代码似乎起源于此 你知道怎么修改

我在GS中找到了这个用于搜索和查找的脚本。这是从2008年开始的,因此早期版本6可能是wirtten,而不是当前版本7。它假设在任何当前选定模板的描述中查找文本,并将其更改为用户键入的任何内容。它正确显示搜索和替换框,并且运行时没有任何错误;但是,没有更改任何文本

我尝试过出版商的论坛和文档;macscripter;还有苹果论坛。我尝试过多次修改它,但是这些更改会产生错误,阻止它运行,或者它运行但没有任何作用

我正在OS 10.13.6上使用GS 7.0.16

代码似乎起源于此

你知道怎么修改吗

set theReply1 to (display dialog "Enter text to replace" default answer "text" buttons {"Cancel", "Continue"} default button "Continue")
set origtext to text returned of theReply1

set theReply2 to (display dialog "Enter new replacement text" default answer "text" buttons {"Cancel", "Continue"} default button "Continue")
set replacetext to text returned of theReply2

to searchReplace(thisText, searchTerm, replacement)
  set AppleScript's text item delimiters to searchTerm
  set thisText to thisText's text items
  set AppleScript's text item delimiters to replacement
  set thisText to "" & thisText
  set AppleScript's text item delimiters to {""}
  return thisText
end searchReplace

tell application "GarageSale"
  repeat with aTemplate in every selected template
    set origline to get the description of aTemplate
    set the description of aTemplate to my searchReplace(origline, origtext, replacetext)
  end repeat
end tell
更新:

我在这里下载了第8版的最新测试版:

上面的代码是为6位用户编写的。出版商显然对脚本语言从6到7做了很多修改。出版商在其网站上提供了当前版本7和beta 8的文档。这些更接近匹配,所以我决定将数据导入到8,并使用Applescript

我通过在beta 8文档中挖掘一些示例,将上面的代码修改为下面的代码。此脚本将找到一个替换单个连续文本行的脚本。您必须从预览模式切换到编辑模式,并复制要替换的html。从预览模式复制样式化文本将不起作用

出版商最终在beta 8中添加了一个批量查找和替换,但它目前在查找包含html的字符串时遇到了问题

您可以使用最新beta 8的内置搜索来查找“这是一些文本”。但它不会找到“这是一些文本”
“更多文本”。上面的脚本将显示此文本

下面的脚本也适用于GS 7.0.16。只需加载到Apple的脚本编辑器中,并在桌面上编译为应用程序即可。选择GS中的一个列表或一个或多个充满列表的文件夹,然后运行编译后的脚本。如果我用另一个大字符串替换一个大字符串,我发现将它们放入两个新的TextEdit文档中会很有帮助,这样我就可以轻松地将它们复制并粘贴到脚本显示的两个对话框中

set theReply1 to (display dialog "Enter text to replace" default answer "text" buttons {"Cancel", "Continue"} default button "Continue")
set origtext to (text returned of theReply1)

set theReply2 to (display dialog "Enter new replacement text" default answer "text" buttons {"Cancel", "Continue"} default button "Continue")
set replaceText to text returned of theReply2

to searchReplace(thisText, searchTerm, replacement)
    set AppleScript's text item delimiters to searchTerm
    set thisText to thisText's text items
    set AppleScript's text item delimiters to replacement
    set thisText to "" & thisText
    set AppleScript's text item delimiters to {""}
    return thisText
end searchReplace

tell application "GarageSale"
    repeat with theListing in (get selected ebay listings)
        set origline to get the description of theListing
        set the description of theListing to my searchReplace(origline, origtext, replaceText)
    end repeat
end tell

如果没有“GarageSale”应用程序,这几乎是不可能解决的。搜索/替换代码工作正常,但如果GS更改了脚本字典,脚本可能会因此失败。你能告诉我们你在哪里下载应用程序,以及你正在使用的应用程序的哪个版本吗?不确定它来自哪里,但应用程序的脚本字典中没有
模板
术语,因此你可以检查你版本的脚本字典,看看有哪些术语可用。应用程序包中也有AppleScript示例(我没有运行应用程序,因此不知道这些示例是否复制到~/Library/application Support/文件夹)。