-1

我在一个文件夹中有多个使用 TextEdit 制作的文本文件。我想使用 AppleScript 查找并替换所有字符串中的相同字符串。

我是 AppleScript 语言的新手。我刚刚用它制作了非常简单的脚本。你能建议我的代码吗?

谢谢。

4

1 回答 1

1

这解决了我的问题。

set myFiles to (choose file with multiple selections allowed)

display dialog "Text to replace" default answer ""
   set textToReplace to text returned of result

display dialog "Text to insert" default answer ""
   set textToInsert to text returned of result

repeat with aFile in myFiles
   set myData to do shell script "cat " & quoted form of (aFile's POSIX path)
   set newData to do shell script "echo " & quoted form of myData & " | sed 's/" & textToReplace & "/" & textToInsert & "/g' > " & quoted form of (aFile's POSIX path)
end repeat
于 2013-12-28T14:40:20.713 回答