1.

Solve : How to go to previous directory form current working directory?

Answer»

Hi,

I have directory like "C:/Program File/Adobe/Acrobat Reader/"

I need a batch script to go to the previous directory "C:/Program File/Adobe/"

Please help me..

Thank You,
JackkQuote

cd "C:\Program File\Adobe\"
This would do it...btw your slashes are WRONG way for windows/dos


To go up to the parent directory, you want to USE "cd ..". When navigating directories ".." represents the parent directory and "." represents the directory you are currently in.

Hope this helps.Hi,

Thanks for the reply,
I tried the script like this

setlocal ENABLEEXTENSIONS

echo %CD%
echo %CD..%

endlocal

it is printing only cd path as "D:\PROJECTFILES\Scripts"
But not cd..
I need to get the the parent path by the batch script.. Please send the batch script.

Thank You,AH! When you said you wanted to "go" to the previous directory PEOPLE understandably thought you wanted to change the current directory to that one. Now it seems you want to obtain the drive & path name of that folder, i.e. obtain the path of the current folder with the final item (this folder name) removed.

Echo the path to the folder above the current one:

for %%A in ("%cd%") do echo %%~dpA
Quote from: jackk on April 26, 2013, 11:19:57 PM
Hi,

Thanks for the reply,
I tried the script like this

setlocal ENABLEEXTENSIONS

echo %CD%
echo %CD..%

endlocal

it is printing only cd path as "D:\PROJECTFILES\Scripts"
But not cd..
I need to get the the parent path by the batch script.. Please send the batch script.

Thank You,
You are confusing a command with a variable.
CD is a command.
%CD% is a variable.Thank you for reply ..

Now it is WORKING..

Thank you


Discussion

No Comment Found