Reputation: 1275
I have a PDF .COMInterop and C# Notes - Notes 1 to 10.pdf
kept in the directory D:\Dropbox\Sample C# Notes
The folder Sample C# Notes
also has some subfolders like 0001, 0002, 0003 and so on till 0100.
I am writing the following command in a batch file to copy the pdf from Sample C# Notes
to all the subfolders inside it (0001, 0002, 0003...)
for /D %%x in (D:\Dropbox\Sample C# Notes\*.*)
DO COPY D:\Dropbox\Sample C# Notes\.COMInterop and C# Notes - Notes 1 to 10.pdf %%x\.COMInterop and C# Notes - Notes 1 to 10.pdf
But it gives an error saying The system cannot find the file specified. Where am I going wrong?
Upvotes: 0
Views: 3142
Reputation:
File/folder names with spaces always need to be double quoted.
for /D %%x in ("D:\Dropbox\Sample C# Notes\*") DO (
COPY "D:\Dropbox\Sample C# Notes\.COMInterop and C# Notes - Notes 1 to 10.pdf" "%%x\"
)
or
PushD "D:\Dropbox\Sample C# Notes\"
for /D %%x in (*) DO (
COPY ".COMInterop and C# Notes - Notes 1 to 10.pdf" "%%x\"
)
PopD
Upvotes: 1