Search code examples
batch-filecmddirectoryparent

CMD change directory to parent directory n times


I don't know very much about cmd so I wonder if there is a shortcut to go n levels up with something like, for example:

cd ..^3

instead of:

cd ../../..

Related.


Solution

  • when typing at the cmd prompt:

    cd .. and enter
    uparrow and enter
    uparrow and enter
    

    In a batch file:

    cd ..
    cd ..
    cd ..
    

    or this:

    for /L %%a in (1,1,3) do cd ..