This post is older than a year. Consider some information might not be accurate anymore.
Used: xubuntu 18.04
Just bought terrific music from Bandcamp and downloaded the FLAC archives. Now I needed to extract them in the terminal console and run into little problems.
These are my files:
tan@omega:~/Music/Bandcamp/We Are All Astronauts$ ls *.zip
We Are All Astronauts - Elysium.zip
We Are All Astronauts - Suspended In A Sunbeam.zip
We Are All Astronauts - The Machines EP.zip
Unzip Problem
If I unzip them like this:
for i in *.zip; do unzip $i; done
The extracted files were all in the same folder, and the cover.jpg got replaced by the next archive.
tan@omega:~/Music/Bandcamp/We Are All Astronauts$ for i in *.zip; do unzip "$i"; done
Archive: We Are All Astronauts - Elysium.zip
extracting: We Are All Astronauts - Elysium - 01 Elysium (Part I).flac
extracting: We Are All Astronauts - Elysium - 02 Elysium (Part II).flac
extracting: cover.jpg
Archive: We Are All Astronauts - Suspended In A Sunbeam.zip
extracting: We Are All Astronauts - Suspended In A Sunbeam - 01 A Mosaic Of Squares.flac
extracting: We Are All Astronauts - Suspended In A Sunbeam - 02 Suspended In A Sunbeam.flac
replace cover.jpg? [y]es, [n]o, [A]ll, [N]one, [r]ename: y
extracting: cover.jpg
Archive: We Are All Astronauts - The Machines EP.zip
extracting: We Are All Astronauts - The Machines EP - 01 We Are All Astronauts feat Sergio Diaz De Rojas - Dark Alleys.flac
extracting: We Are All Astronauts - The Machines EP - 02 We Are All Astronauts - Departure.flac
extracting: We Are All Astronauts - The Machines EP - 03 We Are All Astronauts feat Valeska Rautenberg - Walls Crumble.flac
extracting: We Are All Astronauts - The Machines EP - 04 We Are All Astronauts - Violent Delights.flac
extracting: We Are All Astronauts - The Machines EP - 05 We Are All Astronauts - This Too Shall Pass.flac
extracting: We Are All Astronauts - The Machines EP - 06 We Are All Astronauts & Valeska Rautenberg - Ether.flac
extracting: We Are All Astronauts - The Machines EP - 07 We Are All Astronauts - The Machines EP (continuous mix).flac
replace cover.jpg? [y]es, [n]o, [A]ll, [N]one, [r]ename: y
extracting: cover.jpg
Solution
I want to extract each content in their respective folders. Following command solves my problem:
for i in *.zip; do unzip "$i" -d "${i%%.zip}"; done
The substitution expression "${i%%.zip}"
removes the zip suffix and unzip
uses the archive name as the directory.
tan@omega:~/Music/Bandcamp/We Are All Astronauts$ for i in *.zip; do unzip "$i" -d "${i%%.zip}"; done
Archive: We Are All Astronauts - Elysium.zip
extracting: We Are All Astronauts - Elysium/We Are All Astronauts - Elysium - 01 Elysium (Part I).flac
extracting: We Are All Astronauts - Elysium/We Are All Astronauts - Elysium - 02 Elysium (Part II).flac
extracting: We Are All Astronauts - Elysium/cover.jpg
Archive: We Are All Astronauts - Suspended In A Sunbeam.zip
extracting: We Are All Astronauts - Suspended In A Sunbeam/We Are All Astronauts - Suspended In A Sunbeam - 01 A Mosaic Of Squares.flac
extracting: We Are All Astronauts - Suspended In A Sunbeam/We Are All Astronauts - Suspended In A Sunbeam - 02 Suspended In A Sunbeam.flac
extracting: We Are All Astronauts - Suspended In A Sunbeam/cover.jpg
Archive: We Are All Astronauts - The Machines EP.zip
extracting: We Are All Astronauts - The Machines EP/We Are All Astronauts - The Machines EP - 01 We Are All Astronauts feat Sergio Diaz De Rojas - Dark Alleys.flac
extracting: We Are All Astronauts - The Machines EP/We Are All Astronauts - The Machines EP - 02 We Are All Astronauts - Departure.flac
extracting: We Are All Astronauts - The Machines EP/We Are All Astronauts - The Machines EP - 03 We Are All Astronauts feat Valeska Rautenberg - Walls Crumble.flac
extracting: We Are All Astronauts - The Machines EP/We Are All Astronauts - The Machines EP - 04 We Are All Astronauts - Violent Delights.flac
extracting: We Are All Astronauts - The Machines EP/We Are All Astronauts - The Machines EP - 05 We Are All Astronauts - This Too Shall Pass.flac
extracting: We Are All Astronauts - The Machines EP/We Are All Astronauts - The Machines EP - 06 We Are All Astronauts & Valeska Rautenberg - Ether.flac
extracting: We Are All Astronauts - The Machines EP/We Are All Astronauts - The Machines EP - 07 We Are All Astronauts - The Machines EP (continuous mix).flac
extracting: We Are All Astronauts - The Machines EP/cover.jpg