How to get File Name in File Copy Task - VisualCron - Forum

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


ishelp
10 years ago
I need to get the File name in the File Copy task in order to rename it. I thought there would be a variable for this but can't seem to find anything. Maybe I have been staring at this too long. The files coming in to our system have a date and time in the name and that needs to be stripped off to go to it's destination.

Thanks,

Bill Huber
Sponsor
Forum information
ErikC
10 years ago
Hi Bill, welcome to the forum!

You could use the option 'Post process mask with Variable - use {NEWNAME()} in Variable'.

I do not know how you source filename is, but lets say it's: YYYYMMDDblabla.txt
So the 1st 8 characters are the date.

You need to trip off the 1st 8, so use the substring funtion:
Use this: {STRING(Substring|{NEWNAME()}|8|???)}

We don't know the length of the remaining part, so we need to get the length of the filename and subtract 8 from it.
Use this: {MATH(Add|Integer|{STRING(Length|{NEWNAME()})}|-8|0)}

Now you can combine both by replacing the ??? and you get:
{STRING(Substring||{NEWNAME()}||8|{MATH(Add|Integer|{STRING(Length||{NEWNAME()}|)}|-8|0)})}

This will copy the file to a new filename named: blabla.txt
It might be different in your situation, but this is a way to go.

Regards
Erik
Uses Visualcron since 2006.
Scroll to Top