Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: how to loop files in a folder which has space in it  (Read 2884 times)

0 Members and 1 Guest are viewing this topic.

goody

    Topic Starter


    Newbie

    • Experience: Beginner
    • OS: Windows 10
    how to loop files in a folder which has space in it
    « 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

    Squashman



      Specialist
    • Thanked: 134
    • Experience: Experienced
    • OS: Other
    Re: how to loop files in a folder which has space in it
    « Reply #1 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.