How to remove /volumes/ from my automator service using existing shell script
This is how I'd do it:

toTheClipboard="File Path: afp://serveraddress.com$(sed -e 's: :%20:g' -e 's:/Volumes::' &lt;&lt;&lt; "$1") Parent Folder: afp://serveraddress.com$(dirname "$1" | sed -e 's: :%20:g' -e 's:/Volumes::')"
pbcopy&lt;&lt;&lt;"$toTheClipboard"