我正在使用automator来实现这一目标。这是我正在使用的AppleScript代码(在这里的其他地方找到):
get the clipboard
set the clipboard to (replacement of "/Volumes/" by "afp://servername.com/" for the result)
on replacement of oldDelim by newDelim for sourceString
set oldTIDs to text item delimiters of AppleScript
set text item delimiters of AppleScript to oldDelim
set strtoks to text items of sourceString
set text item delimiters of AppleScript to newDelim
set joinedString to strtoks as string
set text item delimiters of AppleScript to oldTIDs
joinedString
end replacement
get the clipboard
set the clipboard to (replacement of "/Volumes/" by "afp://servername.com/" for the result)
除非我选择多个文件,否则这种方法很有效。有人可以帮忙吗?当输入是多个文件路径时,此代码似乎失败。
答案 0 :(得分:0)
您可以使用以下工作流程:
on run {input, parameters}
set output to {}
repeat with f in input
set end of output to replace(POSIX path of f, "/Volumes/", "afp://servername.com/")
end repeat
set text item delimiters to linefeed
set the clipboard to (output as text)
end run
on replace(input, search, replace)
set text item delimiters to search
set ti to text items of input
set text item delimiters to replace
ti as text
end replace
sed 's|/Volumes/|afp://servername.com/|'|LC_CTYPE=UTF-8 pbcopy