Skip to main content
1 of 2
Kusalananda
  • 355.9k
  • 42
  • 735
  • 1.1k

It's not clear from the question how the files should be renamed, so I'm going to assume that they should be renamed by appending the name of their original directory to their original name.

The code below assumes that your working directory is the directory holding the subdirectories and that each subdirectory has the index.html file, as shown in the question. The index.html files will be moved to a new directory called allfiles.

mkdir allfiles || exit

for pathname in */index.html
do
    mv -- "$pathname" "allfiles/${pathname%/index.html}-index.html"
done

The pathname variable will hold pathnames like A-Dwelling-Place/index.html, and the parameter expansion ${pathname%/index.html} would remove the /index.html bit from the end of that pathname.

Kusalananda
  • 355.9k
  • 42
  • 735
  • 1.1k