Using cmd on Windows, it is easy to assign a drive letter to a UNC path with pushd:
C:\Windows\> pushd \\server\share\path
Y:\> popd
C:\Windows\>
However I would like to be able to do the same with local paths because it will shorten the file paths and I have to use commands that do not support files having a very long path.
The idea is the following without the G:
hardcoded in the script, because it could be used on another machine.
subst G: .
pushd G:\
(other commands)
popd
subst G: /d
I have tried pushd \\?\%CD%
but unfortunately it does not work…
Does anybody have a magic trick for that?
Thank you
This is a temporary solution that I dislike but tries to find programatically the first available drive letter starting from
Z:
as pushd does. I suppose that it can fail easily.If your'e on windows 7 you don't have to use drive letters. You can create a symbolic link instead.
To link to a folder use: