event-based script/cron task to move directories (media management)

Status
Not open for further replies.

Hisma

Explorer
Joined
Mar 23, 2013
Messages
87
Hello

I am a freenas/linux newb in general.

What I would like to know, is if it's possible to set up a cron task, or script of some sort, that is event-based instead of periodic. So, it can detect when a new directory gets created inside of a target directory.

When the script runs, it will search if any of the subdirectories inside the target directory contain words that match with the new directory.

For example, I have a post-processing script in my jail that creates a new directory in my '/TV' directory after it downloads a new show. The show has a name like 'Chopped.S15E02.720p.HDTV.x264-d0rks'. I want to move that directory into where the rest of my Chopped episodes are, entitled 'Chopped'.

So, the script will search if the new directory has any words/words that match with an existing directory. It will then see there is a directory named 'chopped', and move the new show from the '/TV' directory into '/TV/Chopped'.

That's the gist of what I'm trying to do, basically a small event-driven media management script.



Can someone point me in the right direction on how to do this? I want to actually learn how to do it myself, but I'm a scripting newb. I do have basic java/python experience, so if someone can give me some resources to get started, I might be able to figure it out on my own.

But like I said, I'm a newb and have no idea where to start. Hell, there may be a much easier way to do this.

By the way, I think SABnzbd has something like this built in, but I would prefer to have an independent script so -
a) it won't matter if i download the show via torrent or usenet
b) i actually learn something about linux scripting in the process.



Any help is welcome. Like I said, I would like to get pointed in the right direction, and perhaps get some advice.

Thanks!!
 

Caesar

Contributor
Joined
Feb 22, 2013
Messages
114
I think you are in the wrong forums... You should post to a python forum as this is not a simple script also the script you want is not freenas specific. I bet you will find better support/help in the python community than the freenas community.

Also why re-invent the wheel. its not SABnzbd that does what your asking its Sickbeard. and Sick can be configured to use torrent or usenet.
 

Hisma

Explorer
Joined
Mar 23, 2013
Messages
87
I think you are in the wrong forums... You should post to a python forum as this is not a simple script also the script you want is not freenas specific. I bet you will find better support/help in the python community than the freenas community.

Also why re-invent the wheel. its not SABnzbd that does what your asking its Sickbeard. and Sick can be configured to use torrent or usenet.

hi caesar

i think you are right. i know there are some sharp linux guys here, but this is more of a general scripting question than actually targeted at freenas.

by the way, i already mentioned why i want to re-invent the wheel:
so i'm not limited to a specific program (i primarily use transmission for torrents and sabnzbd for usenet)
and
so i can learn about linux scripting for myself

you can close this thread though, seeing as it's not really related to freenas.
 

cyberjock

Inactive Account
Joined
Mar 25, 2012
Messages
19,525
Moved to the "off-topic" section of the forums.
 
Status
Not open for further replies.
Top