There may be times when you want to consolidate all the files in a directory and its sub-directories (or a folder and its sub-folders) into a single directory or folder. For example, you may have a folder with sub-folders for years, and other sub-folders in each year folder for months, and you may want to move files in the month folders all to the top level.
Doing this manually is a complex and time-consuming process. While you might be able to do this by using a search - for example, if all the files are, say, Excel files, you can search for Excel files in the top folder, then just copy them all to a new folder - if there are lots of different types of files, this wouldn't make things easier.
Fortunately, there's a way to do this from a command line. On the BedroomLAN blog, Alexios presents two commands that will do this:
cd $ROOT_DIRECTORY
find -type f -print0 | xargs -0 -I%%% cp %%% $FLAT_DIRECTORY
Replace $ROOT_DIRECTORY with the top level directory containing all the sub-directories and files, and replace $FLAT_DIRECTORY with the directory you wish to contain all the files. Note that this command will overwrite any files with the same name, so if you don't have uniquely named files, it's not ideal.
You can also use the ln command instead of the cp command, and this will not overwrite files, but will give error messages if there are duplicate file names. See the blog post for more details on this.
H/t to robg for pointing this out.
Mac OS X Hints
http://hints.macworld.com/article.php?story=20130224223337451