Auto extracting software for Linux?

3

1

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).

Sirupsen

Posted 2009-12-05T16:15:43.107

Reputation: 630

Question was closed 2014-05-15T14:07:55.600

I'd imagine some combination of cron and batch scripts would do it, but I don't know much about cron. – Macha – 2009-12-05T16:26:36.593

You could make an applciation to do some polling to check for new tarballs. This is interesting... – Linus – 2009-12-05T17:37:17.403

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 – 2009-12-05T18:35:50.733

Answers

2

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.

ngm

Posted 2009-12-05T16:15:43.107

Reputation: 1 593

4

+1 Better way would be to use the inotify command line interfaces http://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 – 2009-12-05T18:20:11.547

Cool, I didn't know about inotify-tools. You're right, that would be much better than constantly polling in the script. – ngm – 2009-12-05T18:25:57.650

0

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.

ngm

Posted 2009-12-05T16:15:43.107

Reputation: 1 593

-1

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

Macha

Posted 2009-12-05T16:15:43.107

Reputation: 4 772

I know that, but I would love this procedure automated. – Sirupsen – 2009-12-05T16:30:43.153

And that's what hackers are about. Probably superusers too... – Nathaniel – 2009-12-05T21:40:02.063