Batch file cd path (path includes %)

Feb 7, 2016
Reaction score
I have been informed that a bunch of folders on our network at work have a folder called Site Plan and one called SitePlan. I've been tasked with going through and consolidating them.

I wrote a batch file that searches the network for such instances. The batch file works well EXCEPT for the fact that someone created folders called 100% CD or some variation of that.

Is there something that can be done to allow the batch file to CD to a folder whose name includes a percent sign?

Here's my current t batch file.
@echo off
if '%1'=='loop1' goto loop1
for /D %%p in (*.*) do call %0 loop1 "%%p"
goto end
cd %2
echo "%CD%"
if not exist "Site Plan" goto next
if not exist SitePlan goto next
echo "%CD%">>q:\test2016-02-10.txt
call %0
cd ..
goto end


Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question