Date
1 - 6 of 6
Automator find and replace text string
Alastair Leith
Is there a basic find and replace text function in Automator? I can only find one for file name strings to use in the Finder (And I don’t want to change any file names, just copy their paths and display in a modified way. Background E.g. /Users/aleith/pCloud\ Drive/Screenshots/reseeding\ coral\ on\ GBR.jpg Then to be kind to non-techies I often replace all escaped characters will just the character and directory symbols “ ➤ “ with and arrow “➤” or something. ➤ Users ➤ aleith ➤ pCloud Drive ➤ Screenshots ➤ reseeding coral on GBR.jpg Apart from fact that Find and Replace in Mail is buggy as hell (only thing that works properly is ‘Replace All', which sometimes is the last thing I want to do as in example above), I figured why not make it all a contextual menu service in Finder so I select the files(s) and it generates a text string which then is copied to the clipboard. I know I can write an AppleScript to do text substitution and copy to Clipboard, and then make that an Automator service, but surprised me I couldn’t find anything in Automator itself other than the Rename Finder Item, the only action that comes up when I search for “replace”. |
|
Shane Stanley
On 17 Jun 2018, at 10:23 pm, Jean-Christophe Helary <brandelune@...> wrote:
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 --
Shane Stanley <sstanley@...> |
|
Alastair Leith
Thanks Steve! So cool, no escape chars either.
toggle quoted message
Show quoted text
On 17 Jun 2018, at 10:28 pm, Steve Mills <sjmills@...> wrote:On Jun 17, 2018, at 06:41, Alastair Leith <qc.student.au@...> wrote:BTW, at some point recently, Apple added command-option-c (IIRC) to Finder’s Edit menu to copy the path[s] of the selection, so you can save a big step here. |
|
2551phil
On 17 Jun 2018, at 21:28, Steve Mills <sjmills@...> wrote: That appeared in El Capitan. FWIW, aside from the keyboard shortcut and the Edit view menu already mentioned, it is also available in a Finder window if you invoke the contextual menu on a selected item and hold down the option key. Best Phil @sqwarq |
|
Alastair Leith
Much obliged, Shane. Thx.
toggle quoted message
Show quoted text
|
|
Shane Stanley
On 18 Jun 2018, at 12:29 am, Alastair Leith <qc.student.au@...> wrote:
Escaping/quoting is only required for the shell, so there's no reason for it to appear anywhere other than Terminal, bash scripts, and do shell script. -- Shane Stanley <sstanley@...> <www.macosxautomation.com/applescript/apps/>, <latenightsw.com> |
|