Delete Files older than [x]

Post Reply
NewScag
Newbie
Posts: 7
Joined: Wed Feb 25, 2015 9:24 am

Delete Files older than [x]

Post by NewScag »

Hello everyone,

I'm trying to make a flow that deletes files automatically, that remained 7 days (or else) in a specific folder.

I want to use it to automatically clean up an output-folder in one of my other flows. This one receives filesthat the users forget to regularly delete, so it gets trashed after time.

Any Ideas?
NewScag
Newbie
Posts: 7
Joined: Wed Feb 25, 2015 9:24 am

Re: Delete Files older than [x]

Post by NewScag »

Btw - already tried the "Stop Job"-tool, but the problem with that is, that switch keeps that explicit-name-code in front of the files as for the program the flow is not yet finished... Really bad to work with those files then.

Is there a way to delete these codes within a flow and not only at its end?
User avatar
gabrielp
Advanced member
Posts: 577
Joined: Fri Aug 08, 2014 4:31 pm
Location: Boston
Contact:

Re: Delete Files older than [x]

Post by gabrielp »

Well... you can put a hold job configurator before a recycle bin, set to 7 days, but that would keep the unique code on the file because Switch needs to track the file in it's internal database so it knows 7 days has elapsed. Another option would be to put the files into a checkpoint and set them to delete after 7 days of no activity, but I think that would also keep the unique switch id as the prefix.

If none of those options would work, I would probably look into using the Inject configurator to export a token of each file, then hold those tokens in a Hold for 7 days, then after 7 days, attempt to do another Inject, this time pulling the original file (using the token to find it). If the file can be injected, remove from its source location and delete. If the inject fails, then the file must have been removed already and the token can be removed.
Chat: open-automation @ gitter
Code: open-automation & dominickp @ GitHub
Tools: Switch, Pitstop, EPMS, Veracore, PageDNA, SmartStream, Metrix
loicaigon
Member
Posts: 147
Joined: Wed Jul 10, 2013 10:22 am

Re: Delete Files older than [x]

Post by loicaigon »

Hi all,

A client of mine had a similar request and I found the best way to deal with it so far was to use Hazel ( http://www.noodlesoft.com/index.php ). You can define rules such as removing files based on their seniority.

FWIW,

Loic
http://www.ozalto.com
lombert
Member
Posts: 166
Joined: Fri Feb 04, 2011 2:31 pm
Location: Sweden

Re: Delete Files older than [x]

Post by lombert »

gabrielp wrote:If none of those options would work, I would probably look into using the Inject configurator to export a token of each file, then hold those tokens in a Hold for 7 days, then after 7 days, attempt to do another Inject, this time pulling the original file (using the token to find it). If the file can be injected, remove from its source location and delete. If the inject fails, then the file must have been removed already and the token can be removed.
Thank you Gabriel. I has tried this now and it works perfect.
Between jobs!
User avatar
gabrielp
Advanced member
Posts: 577
Joined: Fri Aug 08, 2014 4:31 pm
Location: Boston
Contact:

Re: Delete Files older than [x]

Post by gabrielp »

lombert wrote:Thank you Gabriel. I has tried this now and it works perfect.
Glad it worked out. I've used that in several flows and it seems to be the best way of having Switch queue and process jobs over time.

Ever heard of design patterns in programming? They are essentially programming problems you run into time and time again. I feel like if Switch had design patterns, this would be one.
Chat: open-automation @ gitter
Code: open-automation & dominickp @ GitHub
Tools: Switch, Pitstop, EPMS, Veracore, PageDNA, SmartStream, Metrix
Post Reply