Do anyone know if there's some decent software which auto extracts anything which gets downloaded (to f.e. ~/Downloads)? If, let's say, I download x.tar, it would automatically extract it to x (folder).

link|improve this question
I'd imagine some combination of cron and batch scripts would do it, but I don't know much about cron. – Macha Dec 5 '09 at 16:26
You could make an applciation to do some polling to check for new tarballs. This is interesting... – Linus Sjögren Dec 5 '09 at 17:37
The question is unclear, let me rephrase it and see if that's what you want: whenever something new appears in the directory ~/Downloads, this stuff should look at it, identify if it's a tarball or other archive format, and if so extract it to another folder?? – Davide Dec 5 '09 at 18:35
feedback

3 Answers

up vote 2 down vote accepted

You could maybe try a little mini-daemon along the lines of:

#!/bin/bash

DOWNLOAD_DIR=~/Downloads

while true;
do
    for file in $DOWNLOAD_DIR/*.tar*;
    do
        if [ -f $file ]
        then
            tar xf $file
            if [ $? -eq 0 ] # remove if successfully extracted
            then rm $file
            fi
        fi
    done
    sleep 5
done

Just start that running and away you go. I'm not sure what the performance implications of a bash forever loop would be, but just looking at it in top it doesn't seem to be too bad (i.e. it isn't in there.) You could boost the sleep time if necessary.

link|improve this answer
4  
+1 Better way would be to use the inotify command line interfaces inotify-tools.sourceforge.net/#info You could change the script to just run when the folder contents is modified. I think this would be the best way to go about this problem – prestomation Dec 5 '09 at 18:20
Cool, I didn't know about inotify-tools. You're right, that would be much better than constantly polling in the script. – ngm Dec 5 '09 at 18:25
feedback

You could use fsniper, which makes use of inotify.

From the fsniper homepage:

Common uses include making a single drop directory for all things from a webbrowser etc, and having semi-intelligent scripts figure out what to do with those files. You write the scripts yourself.

link|improve this answer
feedback

It's not automatic, but "right click > extract here" for gnome extracts it into a folder of the same name.

link|improve this answer
I know that, but I would love this procedure automated. – Sirupsen Dec 5 '09 at 16:30
And that's what hackers are about. Probably superusers too... – Nathaniel Dec 5 '09 at 21:40
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.