Created
May 20, 2018 23:47
-
-
Save pavel-a/9cfdab4244c7bbbcaf9f32e81dfbaf01 to your computer and use it in GitHub Desktop.
Windows path sanitize (de-space, shorten)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
: Pass path to sanitize as arg 1 | |
@echo off | |
echo Original path=[%~1] | |
call :chkspaces "%~1" | |
if /I NOT "%_sp%" == "%~1" call :shrt "%~1" | |
echo uglified=[%_sp%] | |
goto :EOF | |
:chkspaces | |
set _sp=%1 | |
set _sp=%_sp: =% | |
goto :EOF | |
:shrt | |
echo arg=[%1] | |
set _sp=%~s1 | |
goto :EOF | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
: Shortenize current path. To return, type popd. | |
@echo off | |
echo [%cd%] | |
call :shrt "%cd%" | |
goto :EOF | |
:shrt | |
echo arg=[%1] | |
set _sp=%~s1 | |
echo short=[%_sp%] | |
pushd "%_sp%" | |
goto :EOF |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment