[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: 12
Joined: November 9th, 2009, 5:06 am

[Bash] Run command for every new file downloaded

Post by gevrey » June 2nd, 2019, 9:40 am

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: 6831
Joined: January 22nd, 2008, 2:22 pm

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

Post by sander » June 2nd, 2019, 11:38 am

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
Newbie
Newbie
Posts: 47
Joined: September 2nd, 2017, 3:02 am

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

Post by Puzzled » June 2nd, 2019, 2:45 pm

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: 3507
Joined: April 30th, 2015, 7:35 am
Location: Switzerland
Contact:

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

Post by safihre » 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.

gevrey
Newbie
Newbie
Posts: 12
Joined: November 9th, 2009, 5:06 am

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

Post by gevrey » June 3rd, 2019, 12:50 pm

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

I will try the special option first.

gevrey
Newbie
Newbie
Posts: 12
Joined: November 9th, 2009, 5:06 am

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

Post by gevrey » June 3rd, 2019, 12:53 pm

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: 3507
Joined: April 30th, 2015, 7:35 am
Location: Switzerland
Contact:

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

Post by safihre » June 3rd, 2019, 4:42 pm

Just to note that this only works for Rar files, since it's an option we add to the UnRar command.

Post Reply