Copy all files from a directory tree into one directory

4

I'm running on Windows but have Cygwin so Windows or simple Linux versions are both OK.

My camera-phone stores images in a directory tree based on date, but still appears to name each file uniquely. I want to copy all files into one directory on my PC without all the sub-dirs. How can I do this?

Copying with sub-dir structure is easy: xcopy f:\images\*.jpg C:\Users\Me\Pictures\Phone

Mr. Boy

Posted 2012-07-17T09:37:22.077

Reputation: 3 710

Answers

3

Try this in PowerShell:

dir f:\images -recurse -filt *.jpg | copy -dest C:\Users\Me\Pictures\Phone

Note: - This will overwrite files with the same name already in the destination even if resulting from this copy - Add a -verbose to the copy to see what is being copied.

Richard

Posted 2012-07-17T09:37:22.077

Reputation: 8 152

5

Try this in cygwin:

find /cygdrive/f/images -name '*.jpg' -exec cp '{}' /cygdrive/c/Users/Me/Pictures/Phone \;

mouviciel

Posted 2012-07-17T09:37:22.077

Reputation: 2 858

1try -iname for case-insensitive matches, some cameras use Uppercase. – invert – 2012-07-17T09:55:11.887

And try replacing the \; with + for marginally faster results (this will execute one cp for all the files, rather than one per file). – me_and – 2012-07-17T11:54:26.573

0

Thanks all this was useful thread and Power shell line works perfect

dir f:\images -recurse -filt *.jpg | copy -dest C:\Users\Me\Pictures\Phone

if you have 15 GB of pictures some lost ones don't relay matter anymore.. :D Thanks Richard :)

Toms Millers

Posted 2012-07-17T09:37:22.077

Reputation: 1

1You don't have to repeat someones answer please write a comment instead – yass – 2017-04-23T10:11:38.793

1

@yass is right, that would fit better as a comment. Since you don't have enough reputation to comment, I suggest you read Why do I need 50 reputation to comment? What can I do instead?

– Donald Duck – 2017-04-23T14:20:08.700