Thursday, July 9, 2020
  • Index
  •  » Automator
  •  » A predesigned Automator AppleScript variable has no effect

#1 2020-03-17 06:36:42 am

scrutinizer82
Member
Registered: 2015-08-04
Posts: 39

A predesigned Automator AppleScript variable has no effect

I built the following workflow. It creates a text file from selected text in Safari.

===Beginning of the workflow===

in: Workflow receives selected text in Safari as input

Action #1. "New Text File":

File Format same as input text
Save as "Selected from the web-page [in the square brackets there's an Automator built-in variable of type 'AppleScript' containing the script:
'tell app "Safari"
tell window 1
set TabUrl (the url of the current tab) as text
return TabUrl
end tell
end tell
']"->Variable's name is 'TabUrl'

Where: a chosen folder -- chosen by the user
Encoding: Unicode UTF-8

Action #2. Ask for Confirmation (whether the created file should be opened immediately)

Action #3. Open Finder items with the default application.


===End of the workflow====


My problem is the variable TabUrl placed inside the name field for the file to be created. It's meant to return just plain text, in this case, it's the URL of the current tab where the selection has been made, with the URL then coerced into text. However, upon passing through this action the resulting name omits the output of the AppleScript, although the script is correct and works as expected by itself. Is it because of the special symbols "/" and ":"? But I renamed the file manually in Finder and the system successfully changed the one and only colon in the URL string to "/" leaving the rest in place. I tried enclosing the result in quotes, then tried to replace ":" with "/" - to no avail.
At the same time when I tried to feed it the name of the current tab instead of the URL  it worked.
So, what's going on there and why such a simple snippet of AppleScript script refuses to run in Automator?

Model: MacBook Pro
AppleScript: 2.7
Browser: Safari 605.1.15
Operating System: macOS 10.13

Last edited by scrutinizer82 (2020-03-18 10:54:48 pm)


Currently running Mac OS X 10.7.5, OS X 10.9.5, macOS 10.13.6

Offline

 
  • Index
  •  » Automator
  •  » A predesigned Automator AppleScript variable has no effect

Board footer

Powered by FluxBB

RSS (new topics) RSS (active topics)