So I have a slight problem…I unrared a crapton if files which are now all in their own directories and those directories are inside other directories.


So I want all those text file to just sit in Main not 2 dirs down from there.
If my current directory is Main, I can do this:

find . -type f -iname '*.txt' -exec mv '{}' . \; find . -type d -exec rm -rf '{}' . \;

The above uses the find command to find all the txt files and run the mv command on them moving them to the current dir (Main)
Then, find is also used to find all the Directories, which are now empty, and delete them all using rm -rf

Very, very useful….

Blog Logo

Mario Loria




Because gets old after a while.

Back to Overview