[Bash] Run command for every new file downloaded

Come up with a useful post-processing script? Share it here!
Post Reply
gevrey
Newbie
Newbie
Posts: 25
Joined: November 9th, 2009, 5:06 am
Location: Switzerland

[Bash] Run command for every new file downloaded

Post by gevrey »

Hello,

I cannot find the solution to what I believe is a "simple problem":

I download my movies into a Linux folder: /media/movies
I do not use any subfolder. i.e. all MKV files are under /media/movies
Everytime I download a new movie, I want to run the command "touch" on the file download (and only this file, not on the other files of the /media/movies folder"

I understand that the parameters available to the post-processing scripts are $1, $2, $3

1 The final directory of the job (full path)
2 The original name of the NZB file
3 Clean version of the job name (no path info and ".nzb" removed)

How do I create a script that will do "touch /media/movies/filename.mkv" on each new file downloaded?

Thanks for your help.
User avatar
sander
Release Testers
Release Testers
Posts: 8811
Joined: January 22nd, 2008, 2:22 pm

Re: [Bash] Run command for every new file downloaded

Post by sander »

SAB does not 'feed' all the separate files downloaded towards a post-processing script.

But ... mabye Linux itself (you use Linux, right?) can help: from the post-processing script, run a command "find -cmin -30" to find files which status was changed in the last 30 minutes, and touch those files. I'm assuming/hoping that "status change" only happens on creating, not on accessing ... some tests confirm that.

-cmin n
File's status was last changed n minutes ago.
Puzzled
Full Member
Full Member
Posts: 160
Joined: September 2nd, 2017, 3:02 am

Re: [Bash] Run command for every new file downloaded

Post by Puzzled »

From what I understand, your problem is that the timestamp is from when the mkv was generated, but you want it to be the day you downloaded the file? Unless the mkv file name is always the same as the job name + .mkv I think it would be easier to touch it and then move it to the movies folder.
User avatar
safihre
Administrator
Administrator
Posts: 5338
Joined: April 30th, 2015, 7:35 am
Contact:

Re: [Bash] Run command for every new file downloaded

Post by safihre »

If the problem is what Puzzled describes, you can also use the Config > Special option "ignore_unrar_dates", which will set the date of all unpacked files to the current date/time.
If you like our support, check our special newsserver deal or donate at: https://sabnzbd.org/donate
gevrey
Newbie
Newbie
Posts: 25
Joined: November 9th, 2009, 5:06 am
Location: Switzerland

Re: [Bash] Run command for every new file downloaded

Post by gevrey »

Thanks to all of you guys, that's helpful.

I will try the special option first.
gevrey
Newbie
Newbie
Posts: 25
Joined: November 9th, 2009, 5:06 am
Location: Switzerland

Re: [Bash] Run command for every new file downloaded

Post by gevrey »

safihre wrote: June 3rd, 2019, 1:47 am If the problem is what Puzzled describes, you can also use the Config > Special option "ignore_unrar_dates", which will set the date of all unpacked files to the current date/time.
That solved it. Thanks @safihre
User avatar
safihre
Administrator
Administrator
Posts: 5338
Joined: April 30th, 2015, 7:35 am
Contact:

Re: [Bash] Run command for every new file downloaded

Post by safihre »

Just to note that this only works for Rar files, since it's an option we add to the UnRar command.
If you like our support, check our special newsserver deal or donate at: https://sabnzbd.org/donate
Post Reply