A friend was having trouble getting all the individual images zipped up into a comic file (.cbz) for his favourite manga. He had 209 folders and some notes files, named from Chapter 1 to Chapter 205, with a few in-betweens…he was manually going into each folder, selecting everything and zipping it up…
I offered to help, copied the entire 3.4GB folder into my Linux machine and fired up a terminal.
Firstly, removed all the spaces from the folder names, so instead of Chapter 1, it would be Chapter1 using this oneliner;
for folder in *; do mv $folder ${folder//[[:space:]]}; done
Then used this final oneliner to go into each directory, zip everything into a .cbz using the folder name as the filename;
for dir in $(ls -l | grep '^d'); do cd $dir && zip $dir.cbz && cd ../; done
And voila! The whole process done in under 5 minutes.. the zipping up alone took 2min 43sec on my machine.
He was so impressed he has started to learn Linux. Welcome to the world of computers pal😊
submitted by /u/BobDobby
[link] [comments]