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

User Generated

fhcrecuvy99

Programming

Description

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

User generated content is uploaded by users for the purposes of learning and should be used following Studypool's honor code & terms of service.

Explanation & Answer

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.


Anonymous
Super useful! Studypool never disappoints.

Studypool
4.7
Trustpilot
4.5
Sitejabber
4.4

Similar Content

Related Tags