Sign in to follow this  
Followers 0
DTNGUYEN

Get parent folder

8 posts in this topic

#1 ·  Posted (edited)

I would like to get parent folder path base on @ScriptDir. Please kind to help how to do it.

Eg, @ScriptDir returns "C:\AutoIt\Script

I would like to get "C:\AutoIt" in this case.

Edited by DTNGUYEN

Share this post


Link to post
Share on other sites



Thanks for help. However, i just find out another way to get by using _PathFull

#incllude<file.au3>

@LIB_DIR = _PathFull(@ScriptDir & "..\..\") & "LIB\"

Share this post


Link to post
Share on other sites

StringRegExpReplace(@ScriptDir, '\\[^\\]*$', '')

Slightly off topic...I like this solution, but how would I modify it to only show the parent folder name and trim the left side of the path off. For example:

Have this:

$sPath = "C:\test1\test2\test3\test4\test.xml"

Need this:

$sParent = "test4"

Basically just the parent folder name and not the full path to the parent folder.

Share this post


Link to post
Share on other sites

Have this:

$sPath = "C:\test1\test2\test3\test4\test.xml"

Need this:

$sParent = "test4"

Basically just the parent folder name and not the full path to the parent folder.

Something like this?

$test=StringRegExpReplace(@ScriptDir, '\\[^\\]*$', '')
$test=StringRegExpReplace($test, '.*\\', '')
1 person likes this

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