My question is similar to this one
https://stackoverflow.com/questions/54811336/rename-jpeg-files-sequentially-in-multiple-subfolders
but my folder structure is like this
├── mainfolder
| ├── subfolder1
| | ├── 01folder
|--02folder
|--03folder
|--- 0001.jpg
| | └── 0002.jpg
...
| | └── 0250.jpg
| |
| ├── subfolder2
|── 01folder
|--02folder
|--03folder
| | ├── 0001.jpg
| | └── 0002.jpg
...
| | └── 0250.jpg
| |
| ├── subfolder3
├── 01folder
|--02folder
|--03folder
| | ├── 0001.jpg
| | └── 0002.jpg
...
| | └── 0250.jpg
…
all folders have jpg images numbered from 1 to 250 for a total of 100000 images. I would like to move all the files and rename them before moving them so the folder structure looks like this
├── newfolder
| |--1.jpg
| |--2.jpg
| |--3.jpg
...
| |--100000.jpg
I am currently using this
to move all the files from the nested subdirectories to a new directory
find ~/mainfolder/ -type f -print0 | xargs -0 mv -t ~/newfolder/
not sure how to rename them as well though as they will overwrite each other due to having the same name when moving resulting in only 250 files instead of 100000 files.
0001.jpg
fromsubfolder3
must end up as501.jpg
; or may not, except all files fromsubfolder3
must get consecutive numbers; or they may be "interleaved" in any way. Can there be a gap? likesubfolder10
missing orsubfolder12/0123.jpg
missing? What then? Respective gap in the output numbering? or consecutive numbering no matter what?