Issue with special characters in path (exclamation point !, carrot ^, etc) using batch Delayed Expansion
<p>I have looked around and not been able to find anything to get my script working correctly with special characters (such as <code>!</code> or <code>;</code> or <code>^</code>) in the file path or file name.</p>

<p>My script does work, but only if the above characters are not in any of the scanned folders or file names. If any folders or files have those characters, then the script breaks down. I need help figuring out how to make my script work with special characters (like above) within the path or file name. Here is my script:</p>

<pre><code>set srcdir=%~dp0%src

set desdir=%~dp0%des

setlocal EnableDelayedExpansion
for /r "%srcdir%" %%f in ("*.txt") do (
    set "subdir=%%~f"
    set "subdir=!subdir:%srcdir%=%desdir%!"
    echo !subdir!
    pause
)
endlocal
</code></pre>

<p>Thanks for any and all assistance!</p>