处理文件名中的空格,FOR循环,批处理

时间:2017-10-17 01:18:32

标签: batch-file for-loop input whitespace

我试图找到给定目录中的所有MP3文件,然后将其导出到文件中,然后尝试将文件内容用作输入。

除了包含空格的文件位置外,文件副本的所有实例都正常工作。我应该如何在我当前的代码中解决这个问题。请参阅下面的屏幕截图

我的MP3_Location.txt文件的内容是:

C:\Test\asdad.MP3
C:\Test\New folder\werwer.MP3
C:\Test\OneDrive - Backup\asdasdasdad.MP3

File location with spaces not working

REM Exporting the location of the MP3 file in a given directory 
DIR /s/b "C:\Test\*.MP3" >> C:\Software\MP3_Location.txt

REM Trying to copy the files based on the previous Output 
FOR /F %%G IN (C:\Software\MP3_Location.txt) DO c:\windows\system32\xcopy 
"%%G" C:\Software\MP3\ /Y

编辑1:尝试现在使用Delims,如建议的那样(可能没有正确使用它)

REM Exporting the location of the MP3 file in a given directory
DIR /s/b "C:\Test\*.MP3" >> C:\Software\MP3_Location.txt

REM Trying to copy the files
FOR /F %%G "tokens=* delims=" IN (C:\Software\MP3_Location.txt) DO c:\windows\system32\xcopy "%%G" C:\Software\MP3\ /Y

1 个答案:

答案 0 :(得分:0)

使用命令

FOR /F "delims=" %%G IN
相关问题