Solved this problem with a bash script.

Peace.