Results 1 to 4 of 4
  1. #1
    Join Date
    Nov 2009
    Posts
    134

    Default Automation - How to add a date to a filename for versioning

    Thomas,

    Are there any System Variables available to use in the Automation? Like, if I wanted to name a file and put the Date in the filename? like C:/anydirectory/filename{Date}.csv

    Barry

  2. #2
    Join Date
    Dec 2008
    Posts
    3,225

    Default

    Quote Originally Posted by goodman441 View Post
    Thomas,

    Are there any System Variables available to use in the Automation? Like, if I wanted to name a file and put the Date in the filename? like C:/anydirectory/filename{Date}.csv

    Barry
    There is a fast way that would be more of a programming approach. Create a string variable. Something like FileNameVariable. Then drag an Assign action onto the designer. Enter in FileNameVariable on the left. On the right you will add something like this

    "Websites" + DateTime.Now.ToString("yyyyMMdd") + ".csv"
    That will set the FileNameVariable to Websites20191007.csv.


    Otherwise you could do it with several actions.

    I would create a variable and set the default to something like "Websites{date}.csv". We will replace the {date} with the actual date.

    Drag a "Get Current Date" action. Set that to a CurrentDateVariable.

    Drag a "Convert Date to Format" action. Set the date to the CurrentDateVariable. For the format you will can set it to yyyyMMdd. Then set that result to a ConvertedDateVariable.

    Drag a "Replace Text Value" action. Set the Text to the variable containing "Websites{date}.csv". Set the value to {date}. Set the replacement to that ConvertedDateVariable.

    You should have the same result as the first option.


    Thomas

  3. #3
    Join Date
    Nov 2009
    Posts
    134

    Default

    Quote Originally Posted by TigerSoftware View Post
    There is a fast way that would be more of a programming approach. Create a string variable. Something like FileNameVariable. Then drag an Assign action onto the designer. Enter in FileNameVariable on the left. On the right you will add something like this



    That will set the FileNameVariable to Websites20191007.csv.


    Otherwise you could do it with several actions.

    I would create a variable and set the default to something like "Websites{date}.csv". We will replace the {date} with the actual date.

    Drag a "Get Current Date" action. Set that to a CurrentDateVariable.

    Drag a "Convert Date to Format" action. Set the date to the CurrentDateVariable. For the format you will can set it to yyyyMMdd. Then set that result to a ConvertedDateVariable.

    Drag a "Replace Text Value" action. Set the Text to the variable containing "Websites{date}.csv". Set the value to {date}. Set the replacement to that ConvertedDateVariable.

    You should have the same result as the first option.


    Thomas
    Thomas,

    Thanks for moving this question to it's own thread. I'm sure other people benefit from this info.

    This is exactly what I was wanting....the DateTime.Now.ToString("yyyyMMdd") part of that, is that like a function? Is that a global variable?

    Thanks,
    Barry

  4. #4
    Join Date
    Dec 2008
    Posts
    3,225

    Default

    Quote Originally Posted by goodman441 View Post
    Thomas,

    Thanks for moving this question to it's own thread. I'm sure other people benefit from this info.

    This is exactly what I was wanting....the DateTime.Now.ToString("yyyyMMdd") part of that, is that like a function? Is that a global variable?

    Thanks,
    Barry

    That is a programming function. I would do something like that when I am programming.


    Thomas

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may edit your posts
  •