How to get a batch file to handle spaces in file names?

前端 未结 1 427
清酒与你
清酒与你 2021-01-12 06:53

I am using the following batch file to make a zip file for each xml in a folder:

FOR %%f in (\"C:\\files\\*.xml\") DO 7za.exe a C:\\files\\zips\\%%~nf.zip (%         


        
相关标签:
1条回答
  • 2021-01-12 07:30

    Try placing quotes around the output file name.

    Change

    FOR %%f in ("C:\files*.xml") DO 7za.exe a C:\files\zips\%%~nf.zip (%%f)
    

    to:

    FOR %%f in ("C:\files*.xml") DO 7za.exe a "C:\files\zips\%%~nf.zip" (%%f)
    

    May also be the variable %%f, may need to place quotes around this as well.

    0 讨论(0)
提交回复
热议问题