on searchReplace(theText, SearchString, ReplaceString) | |
set OldDelims to AppleScript's text item delimiters | |
set AppleScript's text item delimiters to SearchString | |
set newText to text items of theText | |
set AppleScript's text item delimiters to ReplaceString | |
set newText to newText as text | |
set AppleScript's text item delimiters to OldDelims | |
return newText | |
end searchReplace | |
on run {input, parameters} | |
set myClip to the input | |
set mytext to searchReplace(myClip, "<", "") | |
set mytext to searchReplace(mytext, ">.", "") | |
set mytext to searchReplace(mytext, ">", "") | |
set findIt to "\\" | |
set replaceIt to "/" | |
set mylocation to searchReplace(mytext, findIt, replaceIt) | |
set mylocation to "smb:" & mylocation | |
tell application "Finder" | |
open location mylocation | |
end tell | |
return input | |
end run |
I am having the same issue. "Can’t get every text item."
any update on this?
@klausmartin I resolved it, somehow.
See code below:
on searchReplace(theText, SearchString, ReplaceString)
set OldDelims to AppleScript's text item delimiters
set AppleScript's text item delimiters to SearchString
set newText to text items of theText
set AppleScript's text item delimiters to ReplaceString
set newText to newText as text
set AppleScript's text item delimiters to OldDelims
return newText
end searchReplace
on run {input, parameters}
set mytext to the input
set mytext to searchReplace(mytext, "<", "")
set mytext to searchReplace(mytext, ">.", "")
set mytext to searchReplace(mytext, ">", "")
set mytext to searchReplace(mytext, " ", "%20")
set findIt to "\\"
set replaceIt to "/"
set mylocation to searchReplace(mytext, findIt, replaceIt)
set mylocation to "smb:" & mylocation
tell application "Finder"
open location mylocation
end tell
return input
end run
The solution to replace spaces with "%20" won't work. You could try "%%20", which should compile to "%20" in the CLI, but that approach will not work in the Mac Terminal. You should simply escape the space using the forward slash - "\ ".
Escaping special characters should always be the preferred method. But be aware, there will be situations where you would have to escape the escape character, e.g. "\\t", depending on what your script is trying to do.
Have a look at https://apple.stackexchange.com/a/144935/7066
using this variant is working for me:
replace
tell application "Finder"
with
tell application "System Events"
Not support if folder has special characters :
| & : ; ( ) < > ~ * @ ? ! $ # [ ] { } \ / ' " `
Any ideas?
I've tried this code and still get the Syntax Error "can't get every text item" like the folks above; Does anyone have an updated solve for this?
I've tried this code and still get the Syntax Error "can't get every text item" like the folks above; Does anyone have an updated solve for this?
So solve the error, don't run the script inside automator.
At the top (in automator) set it from "auto" (translated from german) to "Text" and test it with an actual path.
The script can't do anything inside automator because no text is selected to open.
Running the script Automator throws the alert "every text item can not be read".
Any ideas?