Sign in to follow this  
Followers 0
madasraka

How to get path from multiple files ?

6 posts in this topic

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 :mellow:

Thanks in advance

Share this post


Link to post
Share on other sites



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.

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Hi,

you could try the

_pathsplit()
An example is, where all other examples are....in the helpfile :mellow: Edited by AndyG

Share this post


Link to post
Share on other sites

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 :mellow:

Thank you very much !!!! :P

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

#6 ·  Posted (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 by 99ojo

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