I have spent almost one day and a half searching for this but couldn't find an answer.
I am looking to add the folder's name as a prefix to all files ending with .bin in that folder.
So, if the folder's name is ABC and it contains the files aa.bin, bb.bin, cc.bin, etc. then I need them to be renamed as ABC-aa.bin, ABC-bb.bin, ABC-cc.bin, etc.
Also, this folder ABC has subfolders, let's call them: ABC1, ABC2, ABC3, etc. which also have .bin files. For example ABC1 has aa1.bin, bb1.bin, cc1.bin, etc.
I need that command to go through all folders and append that sub-folder's name to files inside it too. So, aa1.bin will be ABC1-aa1.bin, and so on.
Directory structure:
.
└── ABC
├── aa.bin
├── ABC1
│ ├── aa1.bin
│ └── bb1.bin
├── ABC2
│ ├── aa2.bin
│ └── bb2.bin
├── bb.bin
└── cc.bin