BuckTurgidson
BuckTurgidson

Reputation: 299

batch file for loop with spaces in dir name / (/f "delims=" not working)

Running below

@echo off
setlocal enableDelayedExpansion
set "targetlocation=C:\Users\myself\Documents\FOLDER WITH BLANK SPACES\"
for %%f in (!targetlocation!*) do echo %%f
pause

prints:

C:\Users\myself\Documents\FOLDER
WITH
BLANK
Press any key to continue . . .

I tried to implements the following change, but it fails to run (see source below)

for f/ "delim=" %%f in (!targetlocation!*) do echo %%f

batch file for loop with spaces in dir name

Upvotes: 0

Views: 894

Answers (1)

SachaDee
SachaDee

Reputation: 9545

Try with :

set targetlocation="C:\Users\myself\Documents\FOLDER WITH BLANK SPACES\"

Upvotes: 1

Related Questions