Windows utility written in Go to serve arguments to a "cd" command alias.
In particular this switch:
Use the /D switch to change current drive in addition to changing current
directory for a drive.
I want it to be set automatically.
go install github.com/tischda/gcd@latest
gcd <path>
Examples:
c:\> gcd.exe c:\temp
"c:\temp"
c:\> gcd.exe e:\temp
/d "e:\temp"
c:\> gcd.exe c:\program files
"c:\program files"
To actually change the working directory, define an alias to the cd command:
ncd=FOR /F "delims=" %G IN ('gcd $*') do @cd %G
(I am using cmder)
This fails:
c:\> gcd.exe tips & tricks
"tips"
'tricks' is not recognized as an internal or external command,
operable program or batch file.
Workarounds:
c:\> gcd.exe "tips & tricks"
c:\> gcd.exe tips ? tricks
Using the ncd
alias, this will fail:
c:\> ncd (test)
') was unexpected at this time.
c:\> ncd music ^& videos
The system cannot find the path specified.
'videos' is not recognized as an internal or external command,
operable program or batch file.
Workarounds:
c:\> ncd "(test)"
c:\> ncd (test?
c:\> ncd "music ^& videos"
As a general rule, if it fails, you want to use quoted paths.