Page 1 of 1

[Bash] Run command for every new file downloaded

Posted: June 2nd, 2019, 9:40 am
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.

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

Posted: June 2nd, 2019, 11:38 am
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.

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

Posted: June 2nd, 2019, 2:45 pm
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.

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

Posted: June 3rd, 2019, 1:47 am
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.

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

Posted: June 3rd, 2019, 12:50 pm
by gevrey
Thanks to all of you guys, that's helpful.

I will try the special option first.

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

Posted: June 3rd, 2019, 12:53 pm
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

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

Posted: June 3rd, 2019, 4:42 pm
by safihre
Just to note that this only works for Rar files, since it's an option we add to the UnRar command.