Search code examples
batch-filecmdscriptingwindow

Need to remove extra "\" from a directory path in batch script


I am very new to Batch scripts.

Currently I am writing one batch script and in that I am getting a path from one file like below:

C\\:\\\Program Files\\\Product\\\Install

Now I want it like below:

C:\Program Files\Product\Install

Basically I want to remove those extra \, so how can I achieve this in a easy way?


Solution

  • set "_path=C:\\Program Files\\Product\\Install"
    set "_path=%_path:\\=\%"
    echo %_path%