Search code examples
cmdcommandcd

move to file directly in cmd without exact path


I'm in C:\ folder. Then type cd Sublime Text 3, in order to get to Sublime Text 3, but i doesn't work. I have to type full path C:\Program Files\Sublime Text 3 instead. But there are much longer nested files which path i don't know by heart. Exists any direct command or trick?


Solution

  • You could make yourself a shortcut script such as go.bat. It is somewhat cheezy, but it works.

    @ECHO OFF
    SET EXITCODE=0
    IF "%1" EQU "" (ECHO usage: %0 ^<name^> & GOTO TheEnd)
    IF /I %1 EQU sublime (CD /D "C:\Program Files\Sublime Text 3" & GOTO TheEnd)
    IF /I %1 EQU other (CD /D "C:\Program Files\the\other\one" & GOTO TheEnd)
    IF /I %1 EQU doit (CD /D "C:\Program Files" & GOTO TheEnd)
    ECHO In %0 destination "%1" is unknown.
    SET EXITCODE=1
    :TheEnd
    EXIT /B %EXITCODE%
    

    Then, at the command prompt use:

    go sublime