Skip to content

Instantly share code, notes, and snippets.

@jamesdeluk
Created January 8, 2021 20:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jamesdeluk/65a5342059ee4d2724d5fb268b86f880 to your computer and use it in GitHub Desktop.
Save jamesdeluk/65a5342059ee4d2724d5fb268b86f880 to your computer and use it in GitHub Desktop.
bash--unzip-to-folders
#!/bin/bash
mkdir zips;
for i in *.zip; do
count=`unzip -l $i | rev | cut -d' ' -f2 | rev | xargs`
if [ $count -gt 1 ]; then
filename=`echo ${i:0:-4}`;
mkdir $filename;
unzip -d $filename $i;
else
unzip $i;
fi;
mv $i zips;
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment