I have a dir structure like the following:
[me@mypc]$ tree .
.
├── set01
│ ├── 01
│ │ ├── p1-001a.png
│ │ ├── p1-001b.png
│ │ ├── p1-001c.png
│ │ ├── p1-001d.png
│ │ └── p1-001e.png
│ ├── 02
│ │ ├── p2-001a.png
│ │ ├── p2-001b.png
│ │ ├── p2-001c.png
│ │ ├── p2-001d.png
│ │ └── p2-001e.png
I would like to write a python script to rename all *a.png to 01.png, *b.png to 02.png, and so on. Frist I guess I have to use something similar to find . -name '*.png'
, and the most similar thing I found in python was os.walk
. However, in os.walk
I have to check every file, if it's png, then I'll concatenate it with it's root, somehow not that elegant. I was wondering if there is a better way to do this? Thanks in advance.