I have 2 folders with subdirectories. One with training images and one with training labels.
- One image belongs to exactly one label
- The image and the label have different content
- The image and the label can be found in similar paths.
- The filename (not the extension) is the same
- There can be multiple files in one subdirectory
How can I remove every label which has no corresponding image (and the other way round)? For example:
. |---18 |---a1 | |---a1.webp | |---a11.webp |---a2 | |---a2.webp |---a3
. |---18 |---a1 | |---a1.png | |---a11.png |---a2 | |---a2.png |---a3 |---a3.png
Okayish solution (remove files if there are no corresponding labels or images):
. |---18 |---a1 | |---a1.* | |---a11.* |---a2 | |---a2.* |---a3
Best solution (remove the folders which are empty now, too):
. |---18 |---a1 | |---a1.* | |---a11.* |---a2 |---a2.*
The asterisk* stands for webp or png.