Skip to content

Instantly share code, notes, and snippets.

@jatinsharrma
Created July 4, 2020 15:06
Show Gist options
  • Save jatinsharrma/7089412eb1a2482d067ee53cd44db1d6 to your computer and use it in GitHub Desktop.
Save jatinsharrma/7089412eb1a2482d067ee53cd44db1d6 to your computer and use it in GitHub Desktop.
Extract Multiple ZIP / RAR files from one directory to another. Shell Script
#!/bin/bash
#Script to extract Multiple RAR files and place each RAR file's content in its own directory
for z in *.rar
do
# removing all white space. Generating Directory name
c="$(echo -e "${z}" | tr -d '[:space:]')"
# Creating directory. Replace <Directory Address> with your own Directory Address.
mkdir /<Directory Address>/$c;
# Extracting rar file into its own new Directory. Replace <Directory Address> with your own Directory Address.
unrar x -r "$z" /<Directory Address>/$c;
done
#---------------------------------------------------------------------------
#Script to extract Multiple Zip files and place each RAR file's content in its own directory
for z in *.zip
do
# removing all white space. Generating Directory name
c="$(echo -e "${z}" | tr -d '[:space:]')"
# Creating directory. Replace <Directory Address> with your own Directory Address.
mkdir /<Directory Address>/$c;
# Extracting rar file into its own new Directory. Replace <Directory Address> with your own Directory Address.
unzip "$z" -d /<Directory Address>/$c;
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment