Jump to content
Sign in to follow this  
DTNGUYEN

Get parent folder

Recommended Posts

DTNGUYEN

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
ChrisL
KaFu
Yashied
DTNGUYEN

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
Cyri

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
sahsanu

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, '.*\\', '')
  • Like 1

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.