madasraka Posted May 31, 2010 Posted May 31, 2010 Hey guys! ive been struggling with strings (always do) trying to figure out how to get PATH only. Return value is C:\Users\Administrator\Desktop\System|DN3D_pickups.u|Dweather.u|Dweather.ucl So how do i get C:\Users\Administrator\Desktop\System out of all that knowing that path can be different. I tried to do count and then trim, but if path is not the same then its not gonna work because count will be different. I know i need a For #i = 1 to $returnvalue[0] and something else but not sure what i need to search the string for "|" and once it found do the count of characters so i would know how much to trim. or something like that Thanks in advance
Yoriz Posted May 31, 2010 Posted May 31, 2010 Here is one way. $sString = "C:\Users\Administrator\Desktop\System|DN3D_pickups.u|Dweather.u|Dweather.ucl" $sPathOnly = StringLeft($sString, StringInStr($sString, "\", 0, -1)-1) ConsoleWrite($sPathOnly & @CR) GDIPlusDispose - A modified version of GDIPlus that auto disposes of its own objects before shutdown of the Dll using the same function Syntax as the original.EzMySql UDF - Use MySql Databases with autoit with syntax similar to SQLite UDF.
AndyG Posted May 31, 2010 Posted May 31, 2010 (edited) Hi, you could try the _pathsplit() An example is, where all other examples are....in the helpfile Edited May 31, 2010 by AndyG
madasraka Posted May 31, 2010 Author Posted May 31, 2010 Here is one way. $sString = "C:\Users\Administrator\Desktop\System|DN3D_pickups.u|Dweather.u|Dweather.ucl" $sPathOnly = StringLeft($sString, StringInStr($sString, "\", 0, -1)-1) ConsoleWrite($sPathOnly & @CR) Man this one is awesome Simple and works magic Thank you very much !!!!
sahsanu Posted May 31, 2010 Posted May 31, 2010 Following the Yoriz example but using StringRegExpReplace: $sString = "C:\Users\Administrator\Desktop\System|DN3D_pickups.u|Dweather.u|Dweather.ucl" $sPathOnly = StringRegExpReplace($sString, "(?=.*)\|.*","$1") ConsoleWrite($sPathOnly & @CR) Have a nice day sahsanu
99ojo Posted May 31, 2010 Posted May 31, 2010 (edited) Hi, if you need path and filenames for further coding, i'd use: $sString = "C:\Users\Administrator\Desktop\System|DN3D_pickups.u|Dweather.u|Dweather.ucl" $artemp = StringSplit ($string, "|") MsgBox (0,"", "Path: " & $artemp [1]) For $i = 2 To $artemp [0] MsgBox (0,"", "File: " & $artemp [$i] & @CRLF & "Full Path: " & $artemp [1] & "\" & $artemp [$i]) Next ;-)) Stefan Edited May 31, 2010 by 99ojo
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