how can i copy all .jpg files in a directory but not the subfolders?

Programming
Tutor: None Selected Time limit: 3 Days

how can i copy all .jpg files in a directory but not the subfolders? Like even i the .jpg files are in the subfolders put all .jpg files in one folder

Nov 30th, -0001
This should work:

for /r C:\ %f in (*.jpg) do @copy "%f" D:\pictures\

Explanation:

The command copy "%f" D:\pictures copies the file %f to the location D:\pictures, which is the file pictures in the directory D:\.

Adding a trailing \ to make sure copy treats pictures as a directory.

If you copy multiple files to a single location (e. g., copy *.* D:\backup), copy automatically treats backup as a directory. But this is not the case when you copy a single file.
Jul 16th, 2013

Did you know? You can earn $20 for every friend you invite to Studypool!
Click here to
Refer a Friend
...
Nov 30th, -0001
...
Nov 30th, -0001
Feb 24th, 2017
check_circle
Mark as Final Answer
check_circle
Unmark as Final Answer
check_circle
Final Answer

Secure Information

Content will be erased after question is completed.

check_circle
Final Answer