How to transform a long path to a URL path

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

Post Reply
ineedh3lp
Junior Coder
Posts: 26
Joined: Thu Nov 04, 2010 1:11 am

How to transform a long path to a URL path

Post by ineedh3lp » Fri Aug 19, 2011 6:22 pm

Hello!

How to transform in MS any given long path like

Code: Select all

H:\TEMP\New Folder\tes\1 2 3\xxx\New File.txt
to a URL path like:

Code: Select all

file:///H:/TEMP/New%20Folder/tes/1%202%203/xxx/New%20File.txt
Do I just look for spaces and replace them with %20, add file:/// at the beginning and replace backslashes with slashes?

adroege
Automation Wizard
Posts: 438
Joined: Tue Dec 07, 2004 7:39 pm

Post by adroege » Fri Aug 19, 2011 7:12 pm

Take a look at this link:

http://www.permadi.com/tutorial/urlEncoding/


Then try this:

Code: Select all

VBStart
VBEND


Let>LongPath=H:\TEMP\New Folder\tes\1 2 3\xxx\New File.txt
StringReplace>LongPath,\,/,LongPath
Length>LongPath,len
MidStr>LongPath,3,len,strSub
MidStr>LongPath,1,2,drive

VBEval>escape("%strSub%"),escStr
Let>Prefix=file:///
Let>URL=%Prefix%%drive%%escStr%
MessageModal>URL


ineedh3lp
Junior Coder
Posts: 26
Joined: Thu Nov 04, 2010 1:11 am

Post by ineedh3lp » Fri Aug 19, 2011 7:17 pm

Thank you for the reference and solution!

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts