I have two PDFs - .COMInterop and C# Notes - Notes 1 to 10.pdf
and .COMInterop and C# Notes - Notes 11 to 20.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 0300
.
I am writing the following command (given by SO user lotpings) 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\"
)
How do I modify this code so that I can copy :
.COMInterop and C# Notes - Notes 1 to 10.pdf
into folders 0001
to 0100
and
.COMInterop and C# Notes - Notes 11 to 20.pdf
into folders 0101
to 0300
Try this please:
To make life easier, I didn't use full dir path, instead I changed working path first, and copy files.
Also since you said there are only
0001
to0030
these subfolders, so I didn't check0101
to0300
, just put them in theelse
block.You can improve it based on these.
for /f
used another commanddir
's output.