I want my files to be copied in one folder, the files came from different folder but in the same location.

I run this code in CMD but it copies the folder into new directory.

xcopy "D:\NBS Contents\Latest Images\*.jpg" "D:\output" /s

The latest images folder has many folders containing images files. I want to combine them into one folder.

  • Do you really mean DOS or do you mean CMD? – Bobby Sep 24 '10 at 8:11
  • CMD rather sorry. – text Sep 24 '10 at 8:14
  • You may want to check my answer to the other question. I've made an application that does this, and it handles unexpected situations too, plus shows stats, and has some command-line niceties. – Camilo Martin Dec 27 '10 at 21:58

So in cmd you'll to have to do the below steps

mkdir output
cd "D:\NBS Contents\Latest Images\"
for /r %f in ( "*.jpg" ) do copy /y "%f" "D:\output"

Step by step explaination:

  • D: - switches to D: drive
  • mkdir output - Creates output directory
  • cd "D:\NBS Contents\Latest Images\" - Changes current directory to the one in quotes

  • for /r %f in ( "*.jpg" ) do copy /y "%f" "D:\output" - Recursively, for every jpg file, copy the source file to d:\output. The /y switch suppresses Are you sure you want to overwrite prompt, you can remove the switch if you want the prompt.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.