Assuming I have
dir 1/dir 2/file 1
dir 3/dir 4/file 2
(spaces in directory and file names are intentional)
I want to end up with
dir 1/file 1
dir 3/file 2
This answer moves all the files into the current parent directory (instead of each file's parent directory)
find . -maxdepth 1 -exec mv {} .. \;
This answer prints out each parent directory but I'm not sure how to do the moving.
find . -name '.user.log' | xargs -I{} dirname {}
find -type f -execdir mv "{}" ../ \;
The -execdir
is like -exec
but does its job in a directory where the particular file is, so the ../
part works as you need.
To get rid of empty dir2
and dir4
in your example you need another specialized command, but the main task is done.
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments