1
orzfly 2014-06-17 22:35:13 +08:00
推荐把你的解决方法也发一下方便后人……
|
2
qian OP @orzfly stackoverflow 那位仁兄已经帮忙解决了。额,我这边贴一下我稍微改动的 solution :
snippet 1 on removeText(unwanted, theText) set {TID, text item delimiters} to {text item delimiters, unwanted} set theText to text items of theText set text item delimiters of AppleScript to "" set theText to theText as text set text item delimiters to TID return theText end removeText on replaceText(unwanted, wanted, theText) set {TID, text item delimiters} to {text item delimiters, unwanted} set theText to text items of theText set text item delimiters of AppleScript to wanted set theText to theText as text set text item delimiters to TID return theText end replaceText 把 snippet 1 保存到 Script Libraries (我没看懂 http://macosxautomation.com/mavericks/libraries/index.html 里在说什么,总之不算了我就在 ~/Library 新建名为“Script Libraries”的文件夹,把 text.scpt 放在里面) 以后有需复用 AS text manipulation snippet 的情况,我就把 snippet 扔 text.scpt 里。 实际使用肯定离不开 TextExpander (TE),在 TE 新建一个 AS 文件夹,再新建若干 rules: ASreplace tell script "text" to set theText to replaceText("%filltext:name=old%", "%filltext:name=new%", theText) ASremove tell script "text" to set theText to removeText("old", theText) 在 Hazel 用 AS 利用文件名和 AS text item delimiters 进行文件/文件夹 filing 时,有 TE 就方便许多。 |
3
qian OP 不算了 -> 不管了 (...
|
4
qian OP ...
ASremove tell script "text" to set theText to removeText("%filltext:name=old%", theText) |