| |
| | |

Apple Phoon Forum

 Forgot password?
View: 473|Reply: 1

Replacing Text String in Automator

[Copy link]

Post time: 2014-02-07 14:54:54 |Show all posts
Hey, so I am wondering if anyone could help me with a very simple replace text function in automator that has been driving me a bit crazy. I have created an automated upload and email-notification system for my website, but the URLs that are sent via email contain an extraneous "html/" that prevents the URL from directly linking to the files that are uploaded. So for example, http://bonniebraestudio.com/html/eric/22.png needs to become http://bonniebraestudio.com/html/22.png in order to function. I've tried to find a simple way to remove this text in the automator stack, but the only thing that has worked so far is the "Find and Replace in Text" function from the automated workflows packaged. I am remiss to pay $14.99 for a single script that I only use sparingly, but if I can't find any other way then I'll relent and make the purchase. Otherwise, if there's anyone here who could point me in the write direction, either via applescripts or shell scripts, I'd appreciate it. Most recently I was attempting to use Red_Menace's Change Name of Finder Items script to modify the text, but I keep getting the error "The variable theName is not defined. (-2753), as seen in the screenshot.

         Mac OS X (10.6.8)

Use magic Report

Post time: 2014-02-07 16:40:40 |Show all posts
My action works on file names, so if the Upload to FTP action is returning text it won't work (I'll have to add some error correction for that). Assuming that the action does return text, you can use a Run AppleScript action to remove that portion of the text, for example:
on run {input, parameters} -- remove text from string
set output to {} -- this will be the action's output
set textToRemove to "eric/" -- the text to remove

repeat with anItem in the input -- step through each item in the input
set {tempTID, AppleScript's text item delimiters} to {AppleScript's text item delimiters, textToRemove}
set {textPieces, AppleScript's text item delimiters} to {text items of anItem, tempTID}
set the end of the output to textPieces as text
end repeat

return the output -- pass the result(s) to the next action
end run


Use magic Report

You have to log in before you can reply Login | Register

Archive| Apple Phoon

2021-04-18 07:04 GMT-8 , Processed in 0.090634 sec., 27 queries .

Powered by Discuz! 7.2

Release 20121101, © 2001-2021

To Top