I have to deal with a large number of files nested inside of directories (one file per directory), resembling something like this:
fred/result.txt
john/result.txt
mary/result.txt
...
I am currently using the following command to process each of those files:
find . -maxdepth 1 -type d \( ! -name . \) -exec bash -c \"cd '{}' && processResult result.txt\" \;
I am looking for something I can add into the end of this command that will change the filenames to fred.txt, etc. and then later move the file into the parent directory to eliminate the extra layer of directories.
What would be the best way to do this?
/home/user/some_tests/fred/results.txt. You want that to become/home/user/some_tests/fred.txt. Correcto ? – Sergiy Kolodyazhnyy Mar 16 '16 at 21:34/home/user/some_tests/fred/results.txtto/home/user/some_tests/fred/fred.txtwould be acceptable – DTR Mar 16 '16 at 21:34