0

hello im having an issue with spaces in the %%a attribute inside a Batch FOR.

if i have some files in a folder

yoda jedi.tif
jaba king.tif
solo smug.tif

the following code,

@echo off & setlocal
for /f %%a IN ('dir /b /s "R:\Scans\Epson_v550\*.tif"') do (
echo This was received: %%a
)

results in output of:

This was received: yoda
This was received: jaba
This was received: solo

How can i restructure it so %%a includes the full file name with spaces from %%a?

id like this result:

This was received: yoda jedi.tif
This was received: jaba king.tif
This was received: solo smug.tif

but even when i try,

echo This was received: "%%a"

i still only get back the word before the space. its like %%a is being lopped off at the first space during assignment. Please help?

  • 1
    Possible duplicate of [FOR /F with spaces doesn't work](https://superuser.com/questions/274646/for-f-with-spaces-doesnt-work) – Appleoddity Dec 31 '18 at 06:31

1 Answers1

0

i think I've figured it out, inclusion of the line "delims=" seems to have rectified the space-in-file-names issue.

@echo off & setlocal
for /f "delims=" %%a IN ('dir /b /s "R:\Scans\Epson_v550\*.tif"') do (
echo This was received: %%a
)

This works as desired resulting in:

This was received: yoda jedi.tif
This was received: jaba king.tif
This was received: solo smug.tif

if

yoda jedi.tif
jaba king.tif
solo smug.tif

exist in the specified folder.