2
0

wslpath.cmd 724 B

1234567891011121314151617181920212223242526
  1. @echo off
  2. setlocal EnableExtensions EnableDelayedExpansion
  3. REM Usage: wslpath.cmd -w <linux path>
  4. REM Converts a path from the Linux /mnt/c/... format into Windows format.
  5. REM Usage: wslpath.cmd -u <windows path>
  6. REM Converts a path from Windows to Linux format.
  7. REM Both usages require `wslrun.cmd` in the same directory as this file.
  8. if exist %0\..\wslrun.cmd set WSLRUN="%0\..\wslrun.cmd"
  9. if exist %CD%\%0\..\wslrun.cmd set WSLRUN="%CD%\%0\..\wslrun.cmd"
  10. if "%1" == "-w" goto :towindows
  11. if "%1" == "-u" shift /1
  12. REM Convert path to Linux
  13. if exist "%1\*" (pushd %1) else (pushd %~dp1)
  14. if ERRORLEVEL 1 goto :eof
  15. %WSLRUN% pwd
  16. popd
  17. goto :eof
  18. :towindows
  19. REM Convert path to Windows
  20. %WSLRUN% cd "'%2'" ^&^& cmd.exe /c cd