1

In a batch file I have this code for copying files:

FOR /F "tokens=*" %%f IN ('DIR /S /B *.png,*.jpg,*.pneg,*.jpeg') DO ( XCOPY /H /S /Y /EXCLUDE:%EXFdestination%\EXF.txt %%~f "%destination%\" ) 

Problem is it doesn't copy files with spaces in the filenames like D:\Exemple Directory\file.jpg, it only copies files that have filenames like D:\ExampleDirectory\file.jpg

I tried instead of tokens=* with delims= but it doesn't solve the problem.

2 Answers 2

1

Simple enough: use "%%~f" instead of %%~f

Sign up to request clarification or add additional context in comments.

Comments

0

You could bypass the for loop and use Robocopy.

Here is an example:

ROBOCOPY "C:\Source" "C:\Destination" *.png *.jpg *.pneg *.jpeg /s 

There are also exclude options /XF and /XD, but we have not seen the content of your exclude file EXF.txt.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.