Please note that VisualCron support is not actively monitoring this community forum. Please use our contact page for contacting the VisualCron support directly.


TCG
  •  TCG
  • Free support Topic Starter
2016-05-12T14:15:39Z
Hi Forum Members

We have an interesting conundrum I need your expertise on

We need to copy a file from \\reports\ABC Monthly Report.xls to \\reports\ReadyToEmail\ABC Monthly Report March 2016.xls

The copying part is easy but we have to rename the file at the new destination. The new name should include the month before the month the file were created on

For example if the date created for the ABC Monthly Report.xls is 06 April 2016, then the file at the destination path should be renamed to ABC Monthly Report March 2016.xls

Please help

Thank you
Chris
Sponsor
Forum information
al355
2016-05-12T14:22:14Z
For this you need to use Post process in the Copy files task although will leave it for someone else to reply with the syntax for this example 🙂
TCG
  •  TCG
  • Free support Topic Starter
2016-05-12T14:26:06Z
Thank you for the quick reply. We use the following post process mask at the minute: {PATH(GetFileNameWithoutExtension|{NEWNAME()})} {DATEFORMAT(MMM-yyyy)}.xls

BUT this only adds the current month to the file name, not the previous month

bbusse
2016-05-12T14:59:05Z
I couldn't find a proper variable to use for the 'current' file being copied. Specifically the full path to the file. Just the NEWNAME, but that's not including the path.

So, as long as you're ok with hardcoding the source path (my example uses D:\temp\VisualCron\TCG ), this will work:


{PATH(GetFileNameWithoutExtension|{NEWNAME()})} {FILE(ModifiedTime|D:\temp\VisualCron\TCG\{NEWNAME()}|MMMM yyyy)}.xls


Basically we're still getting the file name without extension as you were before. Then using the File(ModifiedTime) to retrieve the modified date of the source file... but you have to specify the full path to the file, hence D:\Temp\VisualCron\TCG\{NEWNAME()} , and then formatting it how you did, then adding the .xls back.

I could have just been missing the existence of the actively being copied file variable, but i'm going to create a feature request to add a variable similiar to NEWNAME, that is SOURCENAME or something similar that contains the full path that can be manipulated by functions. That way you wouldn't have to hard code anything.

Brian
TCG
  •  TCG
  • Free support Topic Starter
2016-05-12T15:27:24Z
Thank you

I have faffed about with it and managed to get the result we were looking for by using the following post process mask:

{PATH(GetFileNameWithoutExtension|{NEWNAME()})} {DATENOWADD(Months|11|MMMM)} {DATEFORMAT(yyyy)}.xls

Chris
bbusse
2016-05-12T15:31:15Z
Maybe I misunderstood your requirement. But all you're doing by adding 11 months to that date, is using today as the point in time, plus 11 months. It's not in relation to the files date. If you just meant anytime i'm running this job/task in May, it should output April, then yeah, that'll work. I thought you wanted it to be accurate to the file (in case a file that's 2 months old gets processed, lets say).

Brian
TCG
  •  TCG
  • Free support Topic Starter
2016-05-12T16:05:57Z
Hi Bbusse

Yes ideally we want it to be accurate to the file modified date.

How would we go from this {PATH(GetFileNameWithoutExtension|{NEWNAME()})} {FILE(ModifiedTime|D:\temp\VisualCron\TCG\{NEWNAME()}|MMMM yyyy)}.xls to this then {PATH(GetFileNameWithoutExtension|{NEWNAME()})} {DATENOWADD(Months|11|MMMM)} {DATEFORMAT(yyyy)}.xls but instead of using today as the point in time, use the modified date instead?

Chris
bbusse
2016-05-12T17:51:32Z
Feast your eyes on this. 🙂 I had somehow completely skipped the important part... of subtracting a month from the date of the file. Sorry about that.


{PATH(GetFileNameWithoutExtension|{NEWNAME()})} {DATEADD(Months|{FILE(ModifiedTime|D:\temp\VisualCron\TCG\{NEWNAME()}|M/d/yyyy h:mm tt)}|M/d/yyyy h:mm tt|-1|MMMM yyyy)}.xls



So first i looked at the generic "Add number of months to a specified date" variable option. It looks like this:
{DATEADD(Months|5/12/2016 12:44 PM|M/d/yyyy h:mm tt|10|M/d/yyyy h:mm tt)}

That appears to first have a date (5/12/2016 at 12:44 PM), then the format OF that date so it knows how to interpret it, followed by the number of months to add (10), followed by what the output SHOULD look like.

So I set the output of the Modified Time to that same format so it was recognizable, and then made the final output be -1 months from that, and use MMMM yyyy as before.

Brian
TCG
  •  TCG
  • Free support Topic Starter
2016-05-13T08:38:18Z
That's spot on. Thank you very much Brian
bbusse
2016-05-13T12:36:20Z
Originally Posted by: TCG 

That's spot on. Thank you very much Brian



Very welcome. Glad to help. Forces me to think outside the box sometimes haha.

Brian
Scroll to Top