If I choose a zip file and right click "extract here" a folder with the zip filename is created and the entire content of the zip file is extracted into it.
However, I would like to convert several zip files via shell. But when I do
unzip filename.zip
the folder "filename"
is not created but all the files are extracted into the current directory.
I have looked at the parameters but there is no such parameter. I also tried
for zipfile in \*.zip; do mkdir $zipfile; unzip $zipfile -d $zipfile/; done
but the .zip
extension of the 2. $zipfile and 4. $zipfile have to be removed with sed.
If I do
for zipfile in \*.zip; do mkdir sed 's/\.zip//i' $zipfile; unzip $zipfile -d sed 's/\.zip//i' $zipfile/; done
it is not working.
How do I replace the .zip
extension of $zipfile
properly?
Is there an easier way than a shell script?
ls
output for anything.ls
is a tool for interactively looking at directory metadata. Any attempts at parsingls
output with code are broken. Globs are much more simple AND correct:for file in *.zip
. Read Parsing ls – Baer