Skip to content

Instantly share code, notes, and snippets.

@ryanmaclean
Last active September 10, 2016 18:28
Show Gist options
  • Save ryanmaclean/3815f00357135f7b23c5 to your computer and use it in GitHub Desktop.
Save ryanmaclean/3815f00357135f7b23c5 to your computer and use it in GitHub Desktop.
Unzip Zipped Rar Files in Bash
#! /bin/bash
#Script to unpack sceen releases
#Source: http://ubuntuforums.org/archive/index.php/t-1716443.html
#unzip all zip files
for i in `find . -name "*.zip"`; do unzip -o -d `dirname $i` $i;done;
#delete all zip files
for i in `find . -name "*.zip"`; do rm $i;done;
#unrar recusively
find ./* -type f -name '*.rar' -execdir unrar x {} \;
#remove rar
for i in `find . -name "*.r??"`; do rm $i;done;
#remove sample folder
for i in `find . -name "Sample"`; do rm -r $i;done;
#print list of all folders
ls -d */ > dirlist.txt
#keep just the site name
sed 's/_.*//g' dirlist.txt > dirlist2.txt
#remove duplicate entries
cat dirlist2.txt|uniq > dirlist3.txt
#make directories
for d in $(cat dirlist3.txt); do mkdir $d; done
#move directors
for d in $(cat dirlist3.txt); do mv $d?* $d; done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment