0

我正在使用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)

除非我选择多个文件,否则这非常有效。任何人都可以帮忙吗?当输入是多个文件路径时,此代码似乎失败。

4

1 回答 1

1

您可能会使用这样的工作流程:

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
于 2013-11-11T21:01:01.990 回答