I have a bunch of zip files I want to unzip in Linux into their own directory. For example:
a1.zip a2.zip b1.zip b2.zip
would be unzipped into:
a1 a2 b1 b2
respectively. Is there any easy way to do this?
I have a bunch of zip files I want to unzip in Linux into their own directory. For example:
a1.zip a2.zip b1.zip b2.zip
would be unzipped into:
a1 a2 b1 b2
respectively. Is there any easy way to do this?
Add quotes to handle spaces in filename.
for file in *.zip
do
unzip -d "${file%.zip}" "$file"
done
for zipfile in *.zip; do
exdir="${zipfile%.zip}"
mkdir "$exdir"
unzip -d "$exdir" "$zipfile"
done
for x in $(ls *.zip); do
dir=${x%%.zip}
mkdir $dir
unzip -d $dir $x
done
%%
(it deletes the longest match, and there's only one possible match, picky, I know), and it's always good to quote your filenames! –
Blowbyblow Sorry for contributing to an old post, this works in cmd line for me and it was a life saver when I learnt about it
for file in $(ls *.zip); do unzip $file -d $(echo $file | cut -d . -f 1); done
Hey presto!
© 2022 - 2024 — McMap. All rights reserved.