我想制作一个Applescript,在每行文本的开头和结尾添加一些字符,如下所示:
在脚本执行之前:
<div>Something</div>
<div>Something</div>
<div>Something</div>
脚本执行后:
'<div>Something</div>' +
'<div>Something</div>' +
'<div>Something</div>'
你会如何编写类似这样的脚本?任何提示或想法都非常感谢:)
答案 0 :(得分:1)
这样的东西?
set theFile to (choose file) as string
try
set fd to open for access file theFile
set fileContents to read fd as string
close access fd
on error
close access file theFile
return false
end try
set AppleScript's text item delimiters to "' +" & linefeed & "'"
set newFileContents to "'" & (every paragraph of fileContents) & "'" as string
set AppleScript's text item delimiters to ""
try
set fd to open for access file theFile with write permission
set eof of fd to 0
write newFileContents to fd as string
close access fd
on error
close access file theFile
return false
end try
return true