Make \ (backslash) and / (slash) interchangeable in Windows command line

File: slash.cmd

@echo off
set str=%*  
set str=!str:\=/!

REM run the parsed command  

It will execute the command while replace all the \ to /. Like, docker run -it -v %HOME%\test\dir:/workdir debian bash to be docker run -it -v %HOME%/test/dir:/workdir. Since, the Windows command prompt will only auto-complete the path using \ which doesn't work with Docker (linux) paths.

Konpat Preechakul

Read more posts by this author.