Jump to content

Recommended Posts

Posted

If source of location like this 02="C:\New Folder\New Folder\New Folder\New Folder\New Folder\New Folder"

how to make script to get just " C:\New Folder " only..?

Posted (edited)
$iPos = StringInStr($sPath, "\", 0, 2)
$sResult = StringLeft($sPath, $iPos - 1)

 

Edited by water
Only 2 parameters for StringLeft

My UDFs and Tutorials:

  Reveal hidden contents

 

Posted (edited)
Local $sLoc = "C:\New Folder\New Folder1\New Folder2\New Folder3\New Folder4\New Folder5"

MsgBox(0, "StringRegExpReplace", StringRegExpReplace($sLoc, "(.:\\[^\\]+).*", "\1"))

; Or

MsgBox(0, "StringLeft", StringInStr($sLoc, "\", 0, 2) ? StringLeft($sLoc, StringInStr($sLoc, "\", 0, 2) - 1) : $sLoc)

; Or

$iPos = StringInStr($sLoc, "\", 0, 2) ; This will not work if $sLoc = "C:\New Folder" only.
$sResult = StringLeft($sLoc, $iPos - 1) ; @water, note: two parameters only.
ConsoleWrite($sResult & @CRLF)

 

Edited by Malkey
Removed " ; from "C:\New Folder" ;\New Folder1\New Folder2\New Folder3\New Folder4\New Folder5"
Posted
  On 11/6/2016 at 11:32 AM, Malkey said:

@water, note: two parameters only.

Expand  

Fixed :)

My UDFs and Tutorials:

  Reveal hidden contents

 

Posted

As always there are many ways to skin a cat :D

My UDFs and Tutorials:

  Reveal hidden contents

 

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
  • Recently Browsing   0 members

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