I have a main directory, let's say main
. This main directory has some folders, among which are three folders named ccc
ddd
and lll
, which are the only folders I want to target and work on. Each of these subfolders has some folders inside which are all named the same in the three subfolders, so that ccc
ddd
lll
subfolders contain folders of the same name.
Then, each of these subsubfolders that are inside ccc
ddd
lll
has a number of files named with a certain name like this c_000
d_000
l_000
, c_001
d_001
l_001
and so on.
What I want to do first is rename these files so that the directory of their two parents will be attached in the beginning of the file name like this ccc_foo1_c_000
ddd_foo1_d_000
lll_foo1_l_000
and so on. I'm asking if anyone can advise me how this can be done in a .sh
script?
This is a simple tree structure of my main folder:
.
`-- main
|-- ccc
| `-- foO1
| | |-- c_000
| | `-- c_001
| |
-- foo2
| |-- c_000
| `-- c_001
|
|
|-- ddd
| `-- foO1
| | |-- d_000
| | `-- d_001
| |
-- foo2
| |-- d_000
| `-- d_001
|-- lll
| `-- foO1
| | |-- l_000
| | `-- l_001
| |
| -- foo2
| |-- l_000
| `-- l_001
|
|-- aaa
|-- bbb