A task for my assistant

Description

Given a directory with the following structure

── simplicity
│   └── index.html
├── software-engineering-in-sre
│   └── index.html
├── static
│   ├── css
│   │   └── index.min.css?cache=4450b70
│   ├── img
│   │   ├── burger-menu.png
│   │   ├── next-arrow.png
│   │   ├── previous-arrow.png
│   │   └── quote.png
│   └── js
│       ├── detect.min.js?cache=4cb778b
│       └── index.min.js?cache=5b7f90b
├── table-of-contents
│   └── index.html

There are subdirectories simplicity, software-engineering-in-sre, static where all directories except static contain a file named index.html. The static directory contains the css, img and js directories.

The index.html files must be renamed as their parent directory name and suffixed with .html and placed one level above, so that in the end the directory structure becomes

simplicity.html
software-engineering-in-sre.html
table-of-contents.html
├── static
│   ├── css
│   │   └── index.min.css
│   ├── img
│   │   ├── burger-menu.png
│   │   ├── next-arrow.png
│   │   ├── previous-arrow.png
│   │   └── quote.png
│   └── js
│       ├── detect.min.js
│       └── index.min.js

All href links must be fixed so that files correctly link each other.

Your task is to write a program that accomplish the above.

task 2

Given this string <a href="/sre-book/example-postmortem/" I want to convert it to <a href="example-postmortem.html". Do write a program for this