If you have a large amount of files that are in sub-directories and would like them to be in the same directory this will pull all the files into one directory.
NOTE: The ‘find .’ is looking at the specific directory you currently are in. Make sure this is what you want.
Bash
find . -mindepth 2 -type f -print -exec mv {} . \;
# Delete empty directories
find . -depth -empty -type d -exec rm -rfv {} \;Originally Posted on April 9, 2018
Last Updated on October 15, 2025
Last Updated on October 15, 2025
All information on this site is shared with the intention to help. Before any source code or program is ran on a production (non-development) system it is suggested you test it and fully understand what it is doing not just what it appears it is doing. I accept no responsibility for any damage you may do with this code.