OS: Ubuntu 14.04.2 LTS (GNU/Linux 3.13.0-62-generic x86_64)
I have a directory like the following:
~/total/
test1/
test1.txt
some_other_file_i_dont_care.py
test2/
test2.tex
some_folder_i_dont_care/
test3/
test3.csv
I want to move only the text files out of there, and erase their parent folders (which have the same names as the files I'm interested in).
So the result should be this:
~/total/
test1.txt
test2.tex
test3.csv
I think I'm not far from the solution with this function:
find ~/total/ -type f \( -iname '*.txt' -o -iname '*.tex' -o -iname '*.csv' \)
| xargs mv -ifile file ~/total/
But then, how can I remove the remaining folders?