General TC > Programming & Scripting - Unofficial
uncompress script with 7z
jls:
Since there isn't any gui for uncompressing files, I made the below little script which I associated to any compressed file like this (in rox filer):
--- Code: ---aterm +tr +sb -T "Uncompress" -e uncompress "$@"
--- End code ---
the script:
--- Code: ---#!/bin/sh
#jls_legalize unsenepopiu@tin.it
#uncompress in home the passed file with 7z
PROG_NAME=$(basename $0)
if [ ! -f "${1}" ] ; then
echo "Usage: ${PROG_NAME} filename"
exit 2
fi
[ `find /usr/local/tce.installed -name "p7zip*"` ] || MISSING="$MISSING p7zip"
if [ -n "$MISSING" ]; then
echo "The following extension is required: $MISSING"
echo -n "Press Enter key to continue."; read gagme
exit 1
fi
FILE="${1##*/}" ##removes the file path
DESTDIR="$HOME"/"${FILE%.*}" ##removes the file suffix
mkdir "${DESTDIR}"
cd "${DESTDIR}"
7z x "${1}"
echo "press any key to continue"
read ans
--- End code ---
bmarkus:
p7zip is version 4.65 in the repo, released in February while current at http://sourceforge.net/projects/p7zip/files/ is 9.04
Now it supports XZ archives.
Numbering scheme changed :(
jpeters:
Or:
--- Code: ---- FILE="${1##*/}" #removes
- DESTDIR="$HOME"/"${FILE%.*}"
+ DESTDIR="${HOME}/`basename ${1%.*}`"
--- End code ---
mikshaw:
--- Code: ---USER="$(cat /etc/sysconfig/tcuser)"
HOME=/home/"$USER"
--- End code ---
The only time you should have to do this is if you are running the script as root; otherwise the HOME variable is (or should be) already properly set. If you _are_ running the script as root, you'll likely run into problems later on, since you're creating files in a user's directory but not adjusting the ownership of those files.
jls:
ok, I removed the first 2 lines of the script
Navigation
[0] Message Index
[#] Next page
Go to full version