Ryan
Ryan

Reputation: 15250

How can I move matching files into another directory?

I need to move thousands of images:

/Directory/0000/000000.jpg
/Directory/..../.......jpg
/Directory/ZZZZ/ZZZZZZ.jpg

to a flat directory:

/Directory/000000.jpg
/Directory/.......jpg
/Directory/ZZZZZZ.jpg

How can I do this?

Essentially I'm looking for something like this: (but, you know, actually works)

mv -r /Directory/*/*.jpg /Directory

Upvotes: 2

Views: 1546

Answers (1)

Rob I
Rob I

Reputation: 5737

What about:

find /Directory -name \*.jpg -exec mv {} /Directory \;

That should work.

Upvotes: 11

Related Questions