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.

1

You can test this:

mkdir epubs

for f in */*.epub; do 
  mv "$f" epubs/"${f%% *} - $(basename "$f")"
done
1
  • Thanks! This worked flawlessly. – Colar Feb 20 '20 at 20:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.