In my point of view, it's better to put your design in an extension. You will manage it better and faster than in your original design directory ans you will have design and process files in the same place.
Just as Maxime suggested, this is not a task to be handled within presentation layer. It might require programming, therefore you will have to create an extension with some PHP logic. Then you will also need to decide the interface for using your extension from within eZ Publish (HTTP request for a module/view, datatype, template operator, cronjob, etc...) - without that your logic will not be accessible by anything/anyone...