Applescript Apple脚本将剪贴板列表置于引号中

Applescript Apple脚本将剪贴板列表置于引号中,applescript,clipboard,transformation,Applescript,Clipboard,Transformation,有没有人知道一个applescript会将剪贴板上的内容用引号括起来。(理想情况下由快捷键触发,但我可以自己设置) 示例(从excel列复制的数据) 会变成 'Beer','Whisky','Chronic' 我在任何地方都找不到这个,我只能在Applescript中做一些基本的东西,但我完全认为它会帮助很多开发人员/数据库管理员 假设源是纯文本,并且项目由换行符分隔 您可以使用文本项分隔符执行此操作 set theText to "Beer Whisky Chronic" set {TID

有没有人知道一个applescript会将剪贴板上的内容用引号括起来。(理想情况下由快捷键触发,但我可以自己设置)

示例(从excel列复制的数据)

会变成

'Beer','Whisky','Chronic'

我在任何地方都找不到这个,我只能在Applescript中做一些基本的东西,但我完全认为它会帮助很多开发人员/数据库管理员

假设源是纯文本,并且项目由换行符分隔
您可以使用
文本项分隔符执行此操作

set theText to "Beer
Whisky
Chronic"

set {TID, text item delimiters} to {text item delimiters, {linefeed, return}}
set theList to text items of theText
set text item delimiters to "','"
set theResult to "'" & (theList as text) & "'"
set text item delimiters to TID
theResult
要直接从剪贴板获取数据,请将第一行替换为

set theText to the clipboard

假设源是纯文本,并且项目由换行符分隔
您可以使用
文本项分隔符执行此操作

set theText to "Beer
Whisky
Chronic"

set {TID, text item delimiters} to {text item delimiters, {linefeed, return}}
set theList to text items of theText
set text item delimiters to "','"
set theResult to "'" & (theList as text) & "'"
set text item delimiters to TID
theResult
要直接从剪贴板获取数据,请将第一行替换为

set theText to the clipboard

感谢@vadian的帮助-最终的工作脚本 从剪贴板获取输入,转换,然后放回剪贴板

set theText to (do shell script "pbpaste")
set {TID, text item delimiters} to {text item delimiters, {linefeed, return}}
set theList to text items of theText
set text item delimiters to "','"
set theResult to "'" & (theList as text) & "'"
set text item delimiters to TID
set the clipboard to theResult
theResult

我已经使用automator将其设置为一项服务,并指定了一个快捷键进行快速转换。

感谢@vadian在那里提供的帮助-最终的工作脚本 从剪贴板获取输入,转换,然后放回剪贴板

set theText to (do shell script "pbpaste")
set {TID, text item delimiters} to {text item delimiters, {linefeed, return}}
set theList to text items of theText
set text item delimiters to "','"
set theResult to "'" & (theList as text) & "'"
set text item delimiters to TID
set the clipboard to theResult
theResult
我使用automator将其设置为一项服务,并为快速转换分配了一个键盘快捷键