Jump to content

How to get path from multiple files ?


Recommended Posts

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

Link to comment
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.
Link to comment
Share on other sites

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
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...