Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save LeetCodes/187e61fd40d14180f59d1d50c60d2d39 to your computer and use it in GitHub Desktop.

Select an option

Save LeetCodes/187e61fd40d14180f59d1d50c60d2d39 to your computer and use it in GitHub Desktop.
Windows Batch File that takes a quoted text command line argument, removes the quotes, and replaces spaces with underscores
@ECHO OFF
REM Windows Batch File that takes a quoted text command line argument,
REM removes the quotes, and replaces spaces with underscores.
REM This is useful for passing an argument to another program.
REM Change Directory to where the Batch file is saved
CD /d "%~dp0"
set originalquotedtextwithspaces=%1
set noquotes=%originalquotedtextwithspaces:"=%
set withunderscores=%noquotes: =_%
SomeProgram.exe %withunderscores%
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment