Computer Hope

Microsoft => Microsoft DOS => Topic started by: goody on August 29, 2018, 12:36:55 PM

Title: how to loop files in a folder which has space in it
Post by: goody on August 29, 2018, 12:36:55 PM
Hi
I have the following code to copy files from a list. When the path of the files which the folder name has no space, it works perfectly. But the folder names could have space sometimes, how can I improve the code to handle the folder name with space

FOR /F %%a in (find_file_list.txt) DO COPY "%%a" "C:\test\%%~nxa"

Basically, in this find_file_list.txt, there list all files with path

c:\abc\def\12345.txt
c:\abc\def\12346.txt
c:\abc\def\12347.txt

the above code copy all these three files into folder of test and works fine.
Now when find_file_list.txt change, actually the real folder name has space in it, like

c:\ab c\de f\12345.txt
c:\ab c\de f\12346.txt
c:\ab c\de f\12347.txt

the above code not working anymore...
any thoughts?
Thanls
Title: Re: how to loop files in a folder which has space in it
Post by: Squashman on September 07, 2018, 10:05:37 PM
Pretty sure you have been shown how to properly read a file in several of your questions on other forums. Not sure how you keep forgetting to do things.