Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Find all files, and copy them to a folder (Flatten recursively)

Tags:

bash

macos

Basically, I have a very large filesystem that contains media. It has a ton of silly subfolders. I'd like to find all the files (any file) and copy them flatly into a directory. What's the best/easiest way to do this?

assume that the directory of media is located at /home/user/media and the location of the destination directory is /home/user/flatmedia

I'd like to do this using standard mac tools.

like image 691
DrDavid Avatar asked Nov 26 '13 08:11

DrDavid


1 Answers

find /home/user/media -type f -exec cp {} /home/user/flatmedia \;

Note - if there are any duplicates there's no particular guarantee about which one you'll get.

like image 113
GS - Apologise to Monica Avatar answered Sep 24 '22 11:09

GS - Apologise to Monica