I don't know if I'm making sense but, this is roughly what I'm dealing with, and just in case I'll include that some folders have .jpg in the name:
Photos$ tree
.
├── 1
│ ├── 1.jpg
│ │ └── X
│ │ └── Y
│ │ ├── A
│ │ │ └── image.jpg
│ │ └── B
│ │ └── image.jpg
│ └──2.jpg
│ └── X
│ └── Y
│ ├── A
│ │ └── image.jpg
│ └── B
│ └── image.jpg
│
└── 2
├── 1.jpg
│ └── X
│ └── Y
│ ├── A
│ │ └── image.jpg
│ └── B
│ └── image.jpg
├── 2.jpg
│ └── X
│ └── Y
│ ├── A
│ │ └── image.jpg
│ ├── B
│ │ └── image.jpg
Ideally, through the directories names, I would like it to recognize the correct order and rename the images accordingly 1.jpg ... 8.jpg.
If that's too complicated then rename them with their path:
1_1.jpg_X_Y_A_image.jpg
2_2.jpg_X_Y_B_image.jpg
- etc.
... and maybe a way to extract all the actual jpg at once.
I tried (this answer](Rename files with folders' names and move them to one big folder), and I'm guessing I should adapt it better to how many subfolders I have, but I don't know how.
Here's a way I tried to fit in my directory:
user:~/home/test$ mkdir folder
user:~/home/test$ for file in Photos*/*/*.jpg/X*/Y*/*/*.jpg; do
> mv "$file" "folder/${file/\//_}"
> done
the result is always
mv: cannot move 'Photos/1/1.jpg/X/Y/A/image.jpg' to 'folder/Photos/1/1.jpg/X/Y/A/image.jpg': No such file or directory
mv: cannot move 'Photos/2/2.jpg/X/Y/B/image.jpg' to 'folder/Photos/2/2.jpg/X/Y/B/image.jpg': No such file or directory
What am I doing wrong? There are more than a 1000 images, so I can't do this manually!