1: 2: 3:
SET str=A file with a space SET str=%str: =%%20% echo %str%
1: 2: 3: 4: 5: 6: 7:
@echo off setlocal enabledelayedexpansion set str=A file with a space set replace=%%20 set str=%str: =!replace!% echo %str%