Search code examples
windowsbatch-filecopycommand-promptphotos

How to copy ALL photos from a hard drive (batch file)


I have a dilemma. My friend has lots of photos in random folders in his computer, that he would like to back-up onto a flash drive. I was thinking a batch file would be the easiest way to go, assuming manually doing it is out of the question.

So, what could i do to copy ALL the files with a certain extension (in my case .jpg, .gif, and .png) in EVERY subfolder of a hard drive to a flash drive (the batch file would run off said flash drive)

If the batch file is good enough and it does not break stack overflow rules, i may pay a little via paypal to whoever answers :)


Solution

  • You can do directly from the command line without a batch:

    for /r C:\ %x in (*.jpg *.png *.gif) do @copy /y %x .
    

    This will overwrite files with the same name, though.