4

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

3
  • I'd imagine some combination of cron and batch scripts would do it, but I don't know much about cron.
    – Macha
    Dec 5, 2009 at 16:26
  • You could make an applciation to do some polling to check for new tarballs. This is interesting...
    – Linus
    Dec 5, 2009 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, 2009 at 18:35

3 Answers 3

3

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.

3
  • 5
    +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 Dec 5, 2009 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, 2009 at 18:25
  • New link github.com/inotify-tools/inotify-tools/wiki
    – insign
    May 16, 2020 at 18:25
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.

-1

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

2
  • I know that, but I would love this procedure automated.
    – Sirupsen
    Dec 5, 2009 at 16:30
  • And that's what hackers are about. Probably superusers too...
    – Nathaniel
    Dec 5, 2009 at 21:40

Not the answer you're looking for? Browse other questions tagged .