Reputation: 83
I am trying to find all the MP3 files in a given directory, then export it to a file, before trying to use the contents of the file as an input.
All the instances of file copy are working fine, except for the file locations which contain spaces. How should I address this in my current code. Please refer to the screenshot below
Contents of my MP3_Location.txt file are:
C:\Test\asdad.MP3
C:\Test\New folder\werwer.MP3
C:\Test\OneDrive - Backup\asdasdasdad.MP3
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
Edit 1: Trying to use Delims now, as suggested (perhaps not using it correctly)
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
Upvotes: 2
Views: 2551