I need to find the name of the parent directory for a file in DOS
for ex.
Suppose this is the directory
C:\\test\\pack\\a.txt
you can use a vbscript, eg save the below as getpath.vbs
Set objFS = CreateObject("Scripting.FileSystemObject")
Set objArgs = WScript.Arguments
strFile = objArgs(0)
WScript.Echo objFS.GetParentFolderName(strFile)
then on command line or in your batch, do this
C:\test>cscript //nologo getpath.vbs c:\test\pack\a.txt
c:\test\pack
If you want a batch method, you can look at for /?.
%~fI - expands %I to a fully qualified path name
%~dI - expands %I to a drive letter only
%~pI - expands %I to a path only