REMOVE HEX

There has got to be a simpler way of removing hex coeds from a local web link.
can anyone help me.


heres what i got:


[code]
set curr_link to (POSIX file "file:///Volumes/ArtServer/1%5FASI/Tim/ASI%20FILES/TIM%5F11%5F30%5F03%5FM%2DZ%2 0%2D2/S%20ARCHIVE/532842%20sharon%2Eai") as string

set curr_link to SaR(curr_link, "%20", " ") as string
set curr_link to SaR(curr_link, "%21", "!") as string
set curr_link to SaR(curr_link, "%22", "\"") as string
set curr_link to SaR(curr_link, "%23", "#") as string
set curr_link to SaR(curr_link, "%24", "$") as string
set curr_link to SaR(curr_link, "%25", "%") as string
set curr_link to SaR(curr_link, "%26", "&") as string
set curr_link to SaR(curr_link, "%27", "'") as string
set curr_link to SaR(curr_link, "%28", "(") as string
set curr_link to SaR(curr_link, "%29", ")") as string
set curr_link to SaR(curr_link, "%2A", "*") as string
set curr_link to SaR(curr_link, "%2B", "+") as string
set curr_link to SaR(curr_link, "%2C", ",") as string
set curr_link to SaR(curr_link, "%2D", "-") as string
set curr_link to SaR(curr_link, "%2E", ".") as string
set curr_link to SaR(curr_link, "%2F", "/") as string
set curr_link to SaR(curr_link, "%3B", ";") as string
-------set curr_link to SaR(curr_link, "%3C", "<"=") as string
set curr_link to SaR(curr_link, "%3E", ">") as string
set curr_link to SaR(curr_link, "%3F", "?") as string
set curr_link to SaR(curr_link, "%40", "@") as string
set curr_link to SaR(curr_link, "%5B", "[") as string
-----set curr_link to SaR(curr_link, "%5C, "\") as string
set curr_link to SaR(curr_link, "%5D", "]") as string
set curr_link to SaR(curr_link, "%5E", "^") as string
set curr_link to SaR(curr_link, "%5F", "_") as string
set curr_link to SaR(curr_link, "%60", "`") as string
-------set curr_link to SaR(curr_link, "%7D", "}") as string
set curr_link to SaR(curr_link, "%A1", "°") as string
set curr_link to SaR(curr_link, "%A2", "¢") as string
set curr_link to SaR(curr_link, "%A3", "£") as string
---------set curr_link to SaR(curr_link, "%A4", "§") as string
set curr_link to SaR(curr_link, "%A5", "•") as string
set curr_link to SaR(curr_link, "%A8", "®") as string
set curr_link to SaR(curr_link, "%A9", "©") as string




set the clipboard to curr_link
tell application "Finder" to reveal file curr_link


---------FIND CHANGE VERSION1
on SaR(sourceText, findText, replaceText)
set {atid, AppleScript's text item delimiters} to {AppleScript's text item delimiters, findText}
set tempText to text items of sourceText
set AppleScript's text item delimiters to replaceText
set sourceText to tempText as string
set AppleScript's text item delimiters to atid
return sourceText
end SaR

imac, Mac OS X (10.5.8), my computer is fast

Posted on Aug 12, 2010 9:13 AM

Reply
4 replies

Aug 12, 2010 11:16 AM in response to handellphp

to "REMOVE HEX"!!!!!!!!! you need to use the code you have written. Some applications have this code written into them natively and some don't. Either way to change hex to something else you are going to need it. Basically your question should be does Finder or another built in application (yes Finder is an app) from Apple support hex, and the answer to that is I don't know. If your code works though then I'd say stick with it, save it as an exterior handle that you can call anytime you want, and you should be on your way.

Aug 12, 2010 5:35 PM in response to handellphp

Several other scripting languages such as Python and Perl have built-in routines that will decode URLs, so how about this?

<pre style="
font-family: Monaco, 'Courier New', Courier, monospace;
font-size: 10px;
font-weight: normal;
margin: 0px;
padding: 5px;
border: 1px solid #000000;
width: 720px;
color: #000000;
background-color: #DAFFB6;
overflow: auto;"
title="this text can be pasted into the Script Editor">
set curr_link to "file:///Volumes/ArtServer/1%5FASI/Tim/ASI%20FILES/TIM%5F11%5F30%5F03%5FM%2DZ%2 0%2D2/S%20ARCHIVE/532842%20sharon%2Eai"
set curr_link to decodeURL from curr_link
set the clipboard to the result
tell application "Finder" to reveal curr_link as POSIX file


to decodeURL from theTextToDecode
return do shell script "/usr/bin/python -c '" & ¬
"from sys import argv; " & ¬
"from urllib import unquote; " & ¬
"from urlparse import urlparse; " & ¬
"print unquote(urlparse(argv[1])[2])' " & quoted form of theTextToDecode
end decodeURL
</pre>

... or if you want a slightly different one-liner:

<pre style="
font-family: Monaco, 'Courier New', Courier, monospace;
font-size: 10px;
font-weight: normal;
margin: 0px;
padding: 5px;
border: 1px solid #000000;
width: 720px;
color: #000000;
background-color: #DAFFB6;
overflow: auto;"
title="this text can be pasted into the Script Editor">
tell application "Finder" to reveal (do shell script "/usr/bin/python -c 'import sys, urllib; print urllib.unquote(sys.argv[1])' " & quoted form of "file:///Volumes/ArtServer/1%5FASI/Tim/ASI%20FILES/TIM%5F11%5F30%5F03%5FM%2DZ%2 0%2D2/S%20ARCHIVE/532842%20sharon%2Eai") as POSIX file</pre>

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

REMOVE HEX

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.