0

I have a folder with 101 subfolders. Here is a tree with the first ones to visualize the thing:

├── 001 - Implacablement votre
│   └── Implacablement votre - Sapir.epub
├── 002 - Savoir, c'est mourir
│   └── Savoir, c'est mourir T2- Sapir.epub
├── 003 - Puzzle chinois
│   └── Puzzle chinois T3 - Sapir.epub
├── 004 - L'Heroine de la mafia
│   └── L'Heroine de la mafia T4 - Sapir.epub

I'd like to rename the files with the names of their folders (which have the numbers of the books)(I don't care about the - Sapir part) and if it's not too difficult to put all the renamed files in one folder.

I have a basic knowledge of the terminal but that is out of my reach. Thanks a lot if you can help me.

Colar
  • 194

1 Answers1

1

You can test this:

mkdir epubs

for f in */*.epub; do 
  mv "$f" epubs/"${f%% *} - $(basename "$f")"
done