bash - moving files in subdirectories up one (and *only* one) level -
i trying move files nested in subdirectories 1 level. in os x terminal, , new bash. i'm simple, don't know how it.
i want change file structure looks this:
~/container /1-a level 1 - 000.jpg level 1 - 001.jpg level 1 - 002.jpg /1-b /2-a level 2 - 007.jpg level 2 - 008.jpg level 2 - 009.jpg /1-c level 1 - 003.jpg level 1 - 004.jpg level 1 - 005.jpg level 1 - 006.jpg /1-d /2-c level 2 - 010.jpg level 2 - 011.jpg level 2 - 012.jpg level 2 - 013.jpg level 2 - 014.jpg /1-e level 1 - 015.jpg level 1 - 016.jpg level 1 - 017.jpg /1-f /2-b /3-a level 3 - 018.jpg level 3 - 019.jpg level 3 - 020.jpg level 3 - 021.jpg
to 1 looks this:
~/container /1-a level 1 - 000.jpg level 1 - 001.jpg level 1 - 002.jpg /1-b level 2 - 007.jpg level 2 - 008.jpg level 2 - 009.jpg /2-a /1-c level 1 - 003.jpg level 1 - 004.jpg level 1 - 005.jpg level 1 - 006.jpg /1-d level 2 - 010.jpg level 2 - 011.jpg level 2 - 012.jpg level 2 - 013.jpg level 2 - 014.jpg /2-c /1-e level 1 - 015.jpg level 1 - 016.jpg level 1 - 017.jpg /1-f /2-b level 3 - 018.jpg level 3 - 019.jpg level 3 - 020.jpg level 3 - 021.jpg /3-a
i have tried:
find ~/container -mindepth 3 -type f -exec mv {} . \;
and
find ~/container -mindepth 3 -type f -exec mv {} .. \;
but these move files in relation root directory, not directory file in. in other words, move files far up. want them move 1 level, nested begin with.
can help?
this should solve problem:
find ~/container -mindepth 3 -type f -execdir mv "{}" ./.. \;
description:
find ~/container
search inside folder.
-mindepth 3
show files 3 directories down.
-type f
show files (not directories).
-execdir
execute following command on each file inside directory.
mv "{}" ./..
move file 1 directory up.
\;
repeat new command each file selected.
Comments
Post a Comment