AntiVirusGuy Posted May 10, 2006 Share Posted May 10, 2006 ok ill try to explain $var1=C:\Program Files\WinRAR\winrar.exe I want $var2 to equal the file name in this case "winrar.exe" and I want $var3 to equal the path in this case "C:\Program Files\WinRAR\" does anyone know how to do this I tried $var2 = Stringright($var1, StringInStr($var1, '\', 0, -1) -1) Help Link to comment Share on other sites More sharing options...
Don N Posted May 10, 2006 Share Posted May 10, 2006 (edited) Try this $var1="C:\Program Files\WinRAR\winrar.exe" $var2 = StringRight($var1, StringLen( $var1 ) - StringInStr($var1, '\', 0, -1) ) $var3 = StringLeft($var1, StringInStr($var1, '\', 0, -1) ) MsgBox( 0, "", $var1 & @CR & $var2 & @CR & $var3 ) hope that clears everything up Edited May 10, 2006 by Don N _____________________________________________________"some people live for the rules, I live for exceptions"Wallpaper Changer - Easily Change Your Windows Wallpaper Link to comment Share on other sites More sharing options...
BigDod Posted May 10, 2006 Share Posted May 10, 2006 Try $var1 = "c:\Program Files\WinRAR\winrar.exe" $sect = StringSplit($var1,"\") $var2 = $sect[1] & "\" & $sect[2] & "\" & $sect[3] MsgBox(0,"",$var2) $var3 = $sect[4] MsgBox(0,"",$var3) Time you enjoyed wasting is not wasted time ......T.S. Elliot Suspense is worse than disappointment................Robert Burns God help the man who won't help himself, because no-one else will...........My Grandmother Link to comment Share on other sites More sharing options...
AntiVirusGuy Posted May 10, 2006 Author Share Posted May 10, 2006 Thanks guys Don N just what I wanted thanks BigDod not knowing how long the path is that may not work however I think you may have solved a future problem I have not arrived at yet thanks you both Link to comment Share on other sites More sharing options...
Don N Posted May 10, 2006 Share Posted May 10, 2006 For variable length path you can use mine or this modified version of bigdod's $var1 = "c:\Program Files\WinRAR\winrar.exe" $sect = StringSplit($var1,"\") $var2 = "" For $i = 1 To UBound( $sect ) - 2 $var2 = $var2 & sect[$i] & "\" Next MsgBox(0,"",$var2) $var3 = $sect[UBound($sect) - 1] MsgBox(0,"",$var3) _____________________________________________________"some people live for the rules, I live for exceptions"Wallpaper Changer - Easily Change Your Windows Wallpaper Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now