You are not logged in.

#1 2010-02-03 03:43:28

makrin
Member
Registered: 2009-06-09
Posts: 5

Auto extract downloaded files like stuffit expander

Is it possible to do this?
To setup a folder to be watched so that whenever you download any new rar, zip files or other archive formats into that folder it'll automatically extract them (like mac's stuffit expander).
big_smile

Offline

#2 2010-02-03 06:54:50

n0dix
Member
Registered: 2009-09-22
Posts: 956

Re: Auto extract downloaded files like stuffit expander

Why don't you try with a script.

#!/bin/bash

time=4

while [ 1 ] 
do
    unp *.{zip,gz,rar}
    rm *.{zip,gz,rar}
    sleep $time
done

Add the script to the directory of your downloads files.
If important you install unp: http://aur.archlinux.org/packages.php?ID=3939
The script remove the compress files.

Good luck!

Offline

#3 2010-02-03 22:07:15

makrin
Member
Registered: 2009-06-09
Posts: 5

Re: Auto extract downloaded files like stuffit expander

n0dix wrote:

Why don't you try with a script.

#!/bin/bash

time=4

while [ 1 ] 
do
    unp *.{zip,gz,rar}
    rm *.{zip,gz,rar}
    sleep $time
done

Add the script to the directory of your downloads files.
If important you install unp: http://aur.archlinux.org/packages.php?ID=3939
The script remove the compress files.

Good luck!

Cool! smile
Thank You!

Offline

#4 2010-06-20 00:03:47

Tarzanowy
Member
Registered: 2010-06-19
Posts: 2

Re: Auto extract downloaded files like stuffit expander

Thank you! Damn useful script smile

But I'm wondering - in order to extract every downloaded file do I need to have this script running all the time in the background? Or is it somehow possible to trigger it only when a new file appears in the directory?

Offline

#5 2010-06-20 00:10:22

fsckd
Forum Fellow
Registered: 2009-06-15
Posts: 4,173

Re: Auto extract downloaded files like stuffit expander

May be incron can help you there. Never used it though.


aur S & M :: forum rules :: Community Ethos
Resources for Women, POC, LGBT*, and allies

Offline

#6 2010-06-20 13:07:36

rransom
Member
Registered: 2010-04-26
Posts: 92

Re: Auto extract downloaded files like stuffit expander

n0dix wrote:
    unp *.{zip,gz,rar}
    rm *.{zip,gz,rar}

What happens if one of your ZIP files contains another ZIP file?

Offline

#7 2010-06-20 13:10:42

rransom
Member
Registered: 2010-04-26
Posts: 92

Re: Auto extract downloaded files like stuffit expander

Tarzanowy wrote:

But I'm wondering - in order to extract every downloaded file do I need to have this script running all the time in the background? Or is it somehow possible to trigger it only when a new file appears in the directory?

See fsniper (in AUR).

Offline

#8 2010-06-20 14:06:01

simlan
Member
From: Germany
Registered: 2010-05-30
Posts: 20

Re: Auto extract downloaded files like stuffit expander

#!/bin/bash

time=4

while [ 1 ] 
do
    unp *.{zip,gz,rar}

   if [ $? -eq 0 ]
   then rm *.{zip,gz,rar}
fi;
    sleep $time
done

This helps avoiding problems when downloading password protected rar etc... Or do you want to remove all files although they could not been opened?

Offline

#9 2010-06-20 15:30:10

IgnorantGuru
Member
Registered: 2009-11-09
Posts: 640
Website

Re: Auto extract downloaded files like stuffit expander

I would recommend using inotifywait to watch the folder, then run something like xtract to extract the files.  Have this script running all the time:

#!/bin/bash

watchfolder=/downloads

while (( 1 )); do
    inotifywait -e modify -e moved_to -e create $watchfolder
    xtract $watchfolder/*
    sleep 10
done

A little crude but should work.  Better, edit the xtract script so it writes the extracted folders to a different folder instead of the watched one, or use xtract --inter  You might also want to auto-remove the extracted files so they aren't extracted again.

Personally, I prefer just associating xtract with archive types, so when I open them in my file manager they are instantly extracted to a subfolder - no interaction.  You might find that just as easy.

Last edited by IgnorantGuru (2010-06-20 15:35:41)

Offline

#10 2010-06-22 15:41:11

Tarzanowy
Member
Registered: 2010-06-19
Posts: 2

Re: Auto extract downloaded files like stuffit expander

IgnorantGuru wrote:

Personally, I prefer just associating xtract with archive types, so when I open them in my file manager they are instantly extracted to a subfolder - no interaction.  You might find that just as easy.

Thank you! I've been trying to get incron and fsniper to execute my script but they wouldn't listen hmm I'm a bit of a newbie so i think that will do smile

Thanks

Offline

#11 2010-06-22 20:25:50

IgnorantGuru
Member
Registered: 2009-11-09
Posts: 640
Website

Re: Auto extract downloaded files like stuffit expander

Tarzanowy wrote:
IgnorantGuru wrote:

Personally, I prefer just associating xtract with archive types, so when I open them in my file manager they are instantly extracted to a subfolder - no interaction.  You might find that just as easy.

Thank you! I've been trying to get incron and fsniper to execute my script but they wouldn't listen hmm I'm a bit of a newbie so i think that will do smile

I've never used those, only inotifywait, which is very reliable.  But inotifywait doesn't start anything for you, it just watches until the target changes, then quits.  So you use it in a script.  The example script I gave above needs to be saved as "myscript" for example, then started manually with:

bash myscript &

That will keep it running.  Or you can have it start automatically each time you login, which will vary depending on what kind of setup you have (desktop, etc).  That's if you do decide you want the stuffit type folder.

Offline

Board footer

Powered by FluxBB