Unfortunately no one can be told what fun_plug is - you have to see it for yourself.
You are not logged in.
Hi
I found this script to unrar downloaded files. it is really handy and convenient to use. however I would like to modify this script so it would not unpack files to directories they located but a certain directory (mnt/HD_a2/SHARED). Im using "vi" command to change this script but kind of stuck at the moment as Im not sure what lines to leave unchanged.
i understand that "unpack" directory need to be changed and/or the part where unrar directory is mentioned...
if you can point me out how to proceed, i would be most grateful.
script is here:
#!/bin/sh
##############################################################################
# ---[ unpacker.sh ] ---
# script to look for rar files inside a specific directory.
# if found, unrar them
# w 10/29/08 horto
##############################################################################
DLDIR=/mnt/HD_a2/media
LOG=/mnt/HD_a2/logs/unpack.log
UNRAR=/ffp/bin/unrar
# quick and dirty check to make sure no active downloads.
# because we don't want to unrar/delete files that may be actively downloading!
if [ `/ffp/bin/transmission-remote -l | wc -l` -gt 1 ]; then
# stop, because a download is active.
exit 0
else
# continue; because there are no active downloads.
# check incoming DLDIR
for FILE in `find $DLDIR -name "*.rar"`; do
if [ "$FILE" != "*.rar" ]; then
# shell-fu to extract to path containing the rar
FILENAME=`expr //$FILE : '.*/\(.*\)'`
UNPACKDIR=`echo $FILE | sed -e s/$FILENAME//g`
echo [`date`] Extracting "$FILE" ... >> $LOG
# unrar file to the directory its sitting in
$UNRAR x -y "$FILE" "$UNPACKDIR" >> /dev/null 2>&1
echo [`date`] ... done extracting. >> $LOG
# cleanup - remove the rar file(s)
# note: match .rar, .r01, .r02 ... etc
echo [`date`] Removing "$FILENAME and rar files." >> $LOG
for j in `find $UNPACKDIR -name "*.r??"`; do
rm $j
done
fi
done
Offline
I have written a similar script to automatically scan a folder and extract any archives that have not been extracted previously. I am still testing it (and it works) but should have something released in the next few days.
Offline
I would comment out the UNPACKDIR statement in the loop
UNPACKDIR=`echo $FILE | sed -e s/$FILENAME//g`
and create the variable UNPACKDIR in the initialisation part of the script after
UNRAR=/ffp/bin/unrar
with
UNPACKDIR=mnt/HD_a2/SHARED
You might have a problem if a file with the same name exists (bit like setup.exe in windows when unzipping).
I'm not a Linux person either, so you might want to wait for a more informed opinion. :-)
Offline
thanks gasman.
unpacker works.
only thing that "cleanup" part is not functional.
so I changed line in here:
echo [`date`] Removing "$FILENAME and rar files." >> $LOG
for j in `find $UNPACKDIR -name "*.r??"`; do
rm $j
... changed "$UNPACKDIR" to "$DLDIR" and it seems to work now.
just tried with downloaded files. it unpacked file to specified folder "mnt/HD_a2/SHARED" and then deleted .rar files that was unpacked.
so at the moment it'll work as needed!
thanks again.
Offline
Oops, sorry, missed the cleanup part. I *thought* that the rar files would remain in the DLDIR directory.
I did say I was not a linux person. :-)
Offline