(reposting into correct forum)
noob here. I’m trying to pass a URL via Automator to a script that deletes part of the path (or replaces it with “”). Searching around the net, I found some examples of scripts that seem to do this, but they won’t run.
Here is the code I have (it gets its input from a previous action in Automator that gets a URL). It is almost exactly what I’ve found in this same site (and I don’t really understand what it does):
on run {input, parameters}
to switchText of t from s to r
set d to text item delimiters
set text item delimiters to s
set t to t's text items
set text item delimiters to r
tell t to set t to beginning & ({""} & rest)
set text item delimiters to d
t
end switchText
set theText to input as Unicode text
switchText of theText from "javascript:mostrarEvento('/cgi-bin/getProd.asp?xml=" to ""
return theText as string
end run
So I’m just trying to delete that part of the URL, or replace it with nothing (“”). When I run it I get: “Expected “end” but found “to””
Help?
Bruce’s response:
The code runs, but it doesn’t replace the text correctly. The input is a list of URLs:
(
javascript:mostrarEvento('/cgi-bin/getProd.asp?xml=/noticias/calendarioActividades/3/31733/P31733.xml&xsl=/tpl/p43f.xsl&base=/tpl/blanco.xslt');,
javascript:mostrarEvento('/cgi-bin/getProd.asp?xml=/noticias/calendarioActividades/3/31923/P31923.xml&xsl=/tpl/p43f.xsl&base=/tpl/blanco.xslt');,
javascript:mostrarEvento('/cgi-bin/getProd.aspxml=/noticias/calendarioActividades/1/32021/P32021.xml&xsl=/tpl/p43f.xsl&base=/tpl/blanco.xslt');,
)
After the code runs, I get a (non list?) string:
javascript:mostrarEvento('/cgi-bin/getProd.asp?xml=/noticias/calendarioActividades/3/31733/P31733.xml&xsl=/tpl/p43f.xsl&base=/tpl/blanco.xslt');NEWTEXT/javascript:mostrarEvento('/cgi-bin/getProd.asp?xml=/noticias/calendarioActividades/3/31923/P31923.xml&xsl=/tpl/p43f.xsl&base=/tpl/blanco.xslt');NEWTEXT/javascript:mostrarEvento('/cgi-bin/getProd.asp?xml=/noticias/calendarioActividades/1/32021/P32021.xml&xsl=/tpl/p43f.xsl&base=/tpl/blanco.xslt');
First, it doesn’t replace the portion of the URL. Second, it doesn’t seem to pass this as a list of URLs (which is how the input comes in).
I would like to just get the unique URL portion (the numbers) and eventually parse these pages into a format I can import into iCal/gCal. I’m so lost…help please.
I don’t understand enough about the subroutine to fix it. P
Browser: Safari 523.10
Operating System: Mac OS X (10.5)