Page 1 of 1

Compress all files in folder when newest file is older than 30 min

Posted: Wed Apr 14, 2021 3:17 pm
by magnussandstrom
My case: A customer will batch-send hundreds of PDF-files to a folder on our server, every batch of files is one job (a new batch of files will arrive a few times a week). We dont know the exact number of files in every batch, but they will not send multiple batches on the same day.

When new files arrives I want Switch to wait until the last file is transferred to us, and than I want to compress all files in the folder to one zip-file for further processing, and delete the original files.

Since I don't know how many files we are receiving or what time of day the files will arrive I was thinking that I some how can make Switch check when there is new files in the folder and wait 30 minutes after the last change before making the zip file.

Any suggestions how I can create this behaviour in my Switch flow?

Re: Compress all files in folder when newest file is older than 30 min

Posted: Thu Apr 15, 2021 8:09 am
by jan_suhr
Inject Job with "Time of day" as the trigger, could that work for you?

Re: Compress all files in folder when newest file is older than 30 min

Posted: Thu Apr 15, 2021 8:18 am
by magnussandstrom
Inject job "Time of day" might cause us to lose production time. Lets say the batch of files arrives at 7 in the morning and the trigger is set to 12 mid day, we lose 5 hours of valuble production time. Or even worse the trigger is set to 12 mid day and the batch of files starts to arrive 11:59 but all files are not present until 12:02, I will only get half of the files in the ZIP-file. Inject job a specific time of day is not a good solution in this case I think..

Re: Compress all files in folder when newest file is older than 30 min

Posted: Thu Apr 15, 2021 9:48 am
by patej
Would it work to just have an Assemble job before Archive? Set it to assemble by "arbitrary files", "every 10000 jobs" (or anything else too big) with the orphan timeout as 30 minutes ––> files are assembled as a job folder after 30 minutes has passed since the last file.

Re: Compress all files in folder when newest file is older than 30 min

Posted: Thu Apr 15, 2021 8:09 pm
by magnussandstrom
patej wrote: Thu Apr 15, 2021 9:48 am Would it work to just have an Assemble job before Archive? Set it to assemble by "arbitrary files", "every 10000 jobs" (or anything else too big) with the orphan timeout as 30 minutes ––> files are assembled as a job folder after 30 minutes has passed since the last file.
YES! I was trying 'Assemble job' yesterday but I didn't figure out that I could use the 'Orphan timeout' like that. Thank you!