Re: Automator find and replace text string


Shane Stanley
 

On 17 Jun 2018, at 10:23 pm, Jean-Christophe Helary <brandelune@...> wrote:

I don't think I'd use AS for that. I'd use [Run shell script] and do a sed replace on the string you get.

Seems like a bit of overkill for a simple literal replace.

tell application "Finder" to set finderSelectionList to selection as alias list
if length of finderSelectionList = 0 then error "No files were selected in the Finder!"
set thePath to POSIX path of item 1 of finderSelectionList
set saveTID to AppleScript's text item delimiters
set AppleScript's text item delimiters to {"/"}
set thePath to text items of thePath
set AppleScript's text item delimiters to {" "}
set thePath to thePath as text
set AppleScript's text item delimiters to saveTID
set the clipboard to thePath


Join applescript@apple-dev.groups.io to automatically receive all group messages.