Start a new topic

Previous month as a variable?

I would like to archive some files and I am looking for a proper solution. The file name contains the year and month and based on that I would like on firs of April to archive all files crated on March for example. The file name is like Operator_Data_032017.csv and I have tried to create a Job and to use variables, but there is no variable for previous month, only for the current one.

Is there a easy way of creating such a Job or I have to create a script that will pass the previous month as a number to a task?

So a job set to run on the 1st of the month can do a couple things.

Set last_month to be {decrement_start}{MM}{decrement_end}.  If {last_month} is 0, set it to 12.  (Use the Jump task.)

If {last_month} less than 10, set it to 0{last_month} so it has two digits always.  (Another Jump task).

Now you can do a Find in the folder for the pattern:


If the "Operator_Data" is static, you can put that in the pattern too.

This will find the files matching the pattern with that last you can do as you like.

Hi Ben,

Thanks for the prompt replay. In the mid time I found rparse_start and created some user variables. At the end I have the previous month and the year directly as a variable (in the file name I have them both).

days_ms - {math_start:l}{dd}*86400000{math_end}

substr_days - {add_start:-{days_ms}}{now}{add_end}

prev_month - {rparse_start:yyyyMM}{substr_days}{rparse_end}

In this case I don't have to worry about January and use another Jump task. And my Find in the folder looks like this:


Login to post a comment