Search code examples
vbscriptparentrelative-path

Move file to relative parent directory


I know how to get the relative current directory using

.GetParentFolderName(WScript.ScriptFullName)

but how do I get the relative parent of the parent? I'm trying to move a file up 1 directory.


Solution

  • Apply .GetParentFolderName() twice:

    >> WScript.Echo WScript.ScriptFullName
    >> WScript.Echo goFS.GetParentFolderName(WScript.ScriptFullName)
    >> WScript.Echo goFS.GetParentFolderName(goFS.GetParentFolderName(WScript.ScriptFullName))
    >>
    M:\bin\ivbs.wsf
    M:\bin
    M:\
    

    P.S.: the current directory is not necessarily the script's directory (cf. here).