Jewtus Posted June 24, 2015 Share Posted June 24, 2015 Simple command but I couldn't find it when I went looking on the boards. I got the idea while looking for a way to get scriptdir's parent folder (Took the command from HERE)Func GetParent($sDir,$nUpDirs=0) local $sUpdir For $z=0 to $nUpDirs $sUpdir=$sUpdir&"..\" Next $Parent_DIR = _PathFull($sDir&$sUpdir) Return $Parent_DIR EndFuncGive it a path and the number of folders up you want to go and it returns the path. Requires #include <File.au3> Link to comment Share on other sites More sharing options...
Exit Posted June 24, 2015 Share Posted June 24, 2015 Or$sDir = @AppDataDir $sMsg = $sDir & @LF $sMsg &= _GetParentDir($sDir) & @LF $sMsg &= _GetParentDir($sDir, 2) & @LF MsgBox(262144, Default, $sMsg, 0) Func _GetParentDir($sDir, $nUpDirs = 1) Return StringLeft($sDir, StringInStr($sDir, "\", 0, $nUpDirs * -1) - 1) EndFunc ;==>_GetParentDirnow, it's up to the RegEx freaks to show a RegEx solution. EmilyLove 1 App: Au3toCmd UDF: _SingleScript() Link to comment Share on other sites More sharing options...
TheSaint Posted June 24, 2015 Share Posted June 24, 2015 You should have error checking.You should also use something like StringSplit, to tell how many up folders there are, and also cater for the drive letter._PathSplit is probably the better way to go too, and determining whether the original path is to a folder or file. Jewtus 1 Make sure brain is in gear before opening mouth! Remember, what is not said, can be just as important as what is said. Spoiler What is the Secret Key? Life is like a Donut If I put effort into communication, I expect you to read properly & fully, or just not comment. Ignoring those who try to divert conversation with irrelevancies. If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it. I'm only big and bad, to those who have an over-active imagination. I may have the Artistic Liesense to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage) Link to comment Share on other sites More sharing options...
EmilyLove Posted June 30, 2015 Share Posted June 30, 2015 Its called updir, so it can be safely assumed we are dealing with directories and not files Link to comment Share on other sites More sharing options...
TheSaint Posted July 1, 2015 Share Posted July 1, 2015 I suggest you think about that. Directories or folders, also have Up Directories, so the path given could be either a file or folder path. argumentum 1 Make sure brain is in gear before opening mouth! Remember, what is not said, can be just as important as what is said. Spoiler What is the Secret Key? Life is like a Donut If I put effort into communication, I expect you to read properly & fully, or just not comment. Ignoring those who try to divert conversation with irrelevancies. If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it. I'm only big and bad, to those who have an over-active imagination. I may have the Artistic Liesense to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage) Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now