Status
Not open for further replies.

orbofdarkness

Active Member
181
2010
3
0
Hi Everyone,
The following is the script which unrar the files :

for x in *.rar; do mkdir "${x%.rar}" && cd "${x%.rar}" && unrar x "../$x" && cd ..; done

If I am using the sript its extracting the same files into different folders. Also here is a screenshot :-

qov9ud.jpg


But I want A Script That Will Give Me An Output Like The Following Screenshot.

2ag9mc6.jpg



I'm a new user in Ubuntu 9.04 & need a bash script which would delete all the rar files after extraction.

Thanks. TC. Peace Out.

Orb.
 
14 comments
PHP:
#!/bin/bash
# Author : desiboy
# Purpose: to delete all files with .rar extension in a directory
# Date   : Feb-8-2010
# Notes  : The shell file should have execution permissions and user must be a root or should have control over that dir  
rm -f *.rar
 
PHP:
#!/bin/bash
# Author: Avek
# Create folder of each *rar file, unpack rar file there
# and then remove all rar files

for x in *part*.rar
do
  if [ -e "${x%.part*}" ]; then
    echo -ne;
  else
    mkdir "${x%.part*}";
    echo "${x%.part*}";
    rar e "$x" ./"${x%.part*}";
  fi
done
rm -f *part*.rar
#in case that u having *.rar files without part in name
for x in *.rar
do
y=`echo $x | sed 's/.rar//g'`
  if [ -e "$y" ]; then
    echo -ne;
  else
  mkdir "$y";
  rar e "$x" ./"$y";
  fi
done
rm -rf *.rar
I hope that is fine, checked couldn't find any bug but if there's any lemme know
 
Status
Not open for further replies.
Back
Top