You are not logged in.

#1 2007-09-15 16:56:46

test1000
Member
Registered: 2005-04-03
Posts: 834

Do stuff when files put/created in certain folders

Can anyone show me an inotify-tools or similar example on doing what the subject suggests?
for example when text files are dropped in ~ folder then mv $textfile textfilefolder

the best would be if i could have a daemon running and put commands inside a configuration file that would act accordingly depending on what type of file appears.

yeah...


KISS = "It can scarcely be denied that the supreme goal of all theory is to make the irreducible basic elements as simple and as few as possible without having to surrender the adequate representation of a single datum of experience." - Albert Einstein

Offline

#2 2007-09-15 19:03:16

wideeye
Member
Registered: 2006-09-30
Posts: 32

Re: Do stuff when files put/created in certain folders

Offline

#3 2007-09-15 19:18:50

smoon
Member
Registered: 2005-08-22
Posts: 468
Website

Re: Do stuff when files put/created in certain folders

Also there's Sniper. I don't know how well it works though.

*Edit*
The code is there: http://code.l3ib.org/?p=sniper.git

Last edited by smoon (2007-09-15 19:19:59)

Offline

#4 2007-09-16 12:25:41

test1000
Member
Registered: 2005-04-03
Posts: 834

Re: Do stuff when files put/created in certain folders

Thanks man! incrond i finally got working!

I haven't gotten the grips of everytjhing yet, but i have a script in my ~bin called the rather unimaginative mvifimage (couldn't think of another name in my drunken haze...)

#!/bin/bash
#what kind of file is it?
_FILETYPE=`file -i $1|sed 's/.*: //'`

if [ `echo $_FILETYPE|sed 's/\/.*//'` = "image" ];
then
        mv $1 ~/pics
fi

(ofcourse i can extend it to other file types too...)

and then i launch that script from within incrontab -e:

/home/kris IN_CLOSE_WRITE,IN_NO_LOOP /home/kris/bin/mvifimage $@/$#

which automatically moves all fully-downloaded and closed picturefiles dropped in $HOME to my pics folder inside $HOME

woo fu***** hoo! big_smile Iv'e wished i had a program like that for ages and i couldn't get sniper to do what i wanted so... yes!

btw: anyone know a good place we could put this in the wiki?

Last edited by test1000 (2007-09-16 12:27:06)


KISS = "It can scarcely be denied that the supreme goal of all theory is to make the irreducible basic elements as simple and as few as possible without having to surrender the adequate representation of a single datum of experience." - Albert Einstein

Offline

#5 2007-09-24 18:21:52

clownfish
Member
Registered: 2006-09-04
Posts: 72

Re: Do stuff when files put/created in certain folders

sounds great but doesn't work for me...
i installed incron it from aur, added incron to the daemons array in rc.conf and added the line

/home/chris IN_CLOSE_WRITE echo "worx" > /home/chris/incrontest

to the incrontable via "incrontab -e"

according to htop, /usr/sbin/incrond is up and running.
i already tried to create the file /etc/incron.allow with my username in it (like you do with cron -> cron.allow)

but nothing happens. any idea?

thx

Last edited by clownfish (2007-09-24 19:11:21)

Offline

#6 2007-09-24 22:44:20

test1000
Member
Registered: 2005-04-03
Posts: 834

Re: Do stuff when files put/created in certain folders

uhh i don't know why that doesn't work hmm maybe one have to put the cmd into a script as the entry need to look like /path/to/hell BLA_BLA cmd $PARAMETERS

because with my script it still works... try it and you'll see...


KISS = "It can scarcely be denied that the supreme goal of all theory is to make the irreducible basic elements as simple and as few as possible without having to surrender the adequate representation of a single datum of experience." - Albert Einstein

Offline

#7 2007-09-25 08:51:00

clownfish
Member
Registered: 2006-09-04
Posts: 72

Re: Do stuff when files put/created in certain folders

jep, i tried that, but didn't work. i already wrote a script "drop-in" which is called by incron and executes a script according to the file type (mime-type and extension) of the given file. even with some tiny statistic capabilities...
but i never tried if incron works before i wrote the script, cause incron looked pretty simple.
now i have a script but incron is on strike.

Offline

#8 2007-09-25 09:07:38

clownfish
Member
Registered: 2006-09-04
Posts: 72

Re: Do stuff when files put/created in certain folders

/me = stupid
had a look at it again, tried with the script - now it works, except the script needs some debugging. maybe i forgot to call the script the first time i tried it: the script is placed in /home/chris/scripts/drop-in/drop-in; probably the first time i tried it, i just wrote /home/chris/scripts/drop-in (which is actually just the path to the script) into the incron table...

maybe i'll post the script when it's not that buggy anymore.

Offline

Board footer

Powered by FluxBB