Extracting 1 to 5 zip files isn't a hard job, we just choose the files then right-click on the files then choose extract.
How about extracting many zip files, for example 100 files or maybe 1000 files. Well, this job really become tedious and frustrating (honestly, i ever do this hard job, its torture me, believe me....). so, what is the solution?
I finishing him (i mean the problem), with making a bash shell script (i got this idea from book "Mastering Unix Shell Scripting" by Randal K. Michael published by wiley). here the script (i hope you already knew what kind of creature is shell script he he he..):
#!/bin/sh
# extract.sh, created at 15 February 2009
# (c) Juan Rio Sipayung aka Joielechong, GPL
# This Script will extracting all file in this script current directory
# to '/destination', you can change '/destination' to whatever destination
# folder you want e.g '/home/user' or '/tmp', of course
# you must have the write permission.
# This variable use to store the numbers of zip file being extracted
count=0
# Do extracting each zip file until no more
for file in *.zip
do
# unzipping file, -d option allows extraction in an arbitrary directory
# here we extracting to '/destination' as example, change '/destination'
#to your destination folder
unzip $file -d /destination
# Count each zip file being extracted
count=$(($count+1))
done
# This part telling user that no zip file in the current directory
# Still not working i don't know why, if you know tell me :).......
#if [ "$count" = 0 ]; then
# echo "No zip file is extracted"
#fi
# show how many the zip file being extracted
if [ "$count" != 0 ]; then
echo "$count zip file extracted"
echo "Extracting complete"
fi
exit 0
Save this source code and name it extract.sh, and put it on the folder where your zip files are, then run it from terminal and wait for the result :).....
notes:
1. Every single step was done on system with Slackware 12.2 with KDE desktop manager.
2. This script can be use to extracting rar file, tar.gz file or other compression file type, of course you must do a couple change to this script.
Happy Hacking,
Juan Rio Sipayung
Tuesday, 31 March 2009
Subscribe to:
Post Comments (Atom)
Category
- books (1)
- Game (1)
- news (1)
- Programming (3)
- Software (5)
- System (1)
- Terminology (1)
No comments:
Post a Comment