Sign in to follow this  
Followers 0
AntiVirusGuy

Strings

5 posts in this topic

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

Share this post


Link to post
Share on other sites



#2 ·  Posted (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 by Don N

_____________________________________________________"some people live for the rules, I live for exceptions"Wallpaper Changer - Easily Change Your Windows Wallpaper

Share this post


Link to post
Share on other sites

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)


Get Beta versions Here Get latest SciTE editor Here AutoIt 1-2-3 by Valuater - A great starting point.

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

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0