KAPOW

Would you like to react to this message? Create an account in a few clicks or log in to continue.
KAPOW

Welcome to the Kapow forum. Here you can get help, use your skills to help others and enjoy hanging out in the company of other Kapow Robot Developers.


2 posters

    Create folder with its name as current date

    avatar
    junwei


    Posts : 16
    Points : 2057
    Join date : 2018-10-16

    Create folder with its name as current date Empty Create folder with its name as current date

    Post by junwei Thu Dec 27, 2018 10:16 am

    Hi all, 

    Just want to ask how can I create a folder using the "Make Directory" action in Kapow to have the current date created.
    For example, to make a folder is C:\User\Kapow\folder. Where 'folder' is the name of the file.

    However, I want the name of the file to be the current date, say 27-Dec 2018. How can I perform this action using the dd-MMMM yyyy step?
    Can someone advise on this? Thanks a lot for your help.
    jking
    jking


    Posts : 103
    Points : 3863
    Join date : 2014-03-01
    Location : USA

    Create folder with its name as current date Empty Re: Create folder with its name as current date

    Post by jking Thu Dec 27, 2018 8:52 pm

    In your Make Directory Step, click the drop-down box next to Directory: and Select Expression.
    Edit Expres​sion(or type directly in the Directory box).
    Expression is "C:\\User\\Kapow\\"+date()
    Output is C:\User\Kapow\2018-12-27


    If you want a specific date format:
    Create a DateVariable
    Use an Assign Variable step to assign date() and format as needed
    Add a Make Directory Step,  click the drop-down box next to Directory: and Select Expression.
    Edit Expres​sion(or type directly in the Directory box).
    Expression is "C:\\User\\Kapow\\"+DateVariable
    Output is C:\User\Kapow\27-12-2018
    avatar
    junwei


    Posts : 16
    Points : 2057
    Join date : 2018-10-16

    Create folder with its name as current date Empty Re: Create folder with its name as current date

    Post by junwei Fri Dec 28, 2018 4:06 pm

    Hi Jking, 

    Thanks for the help, it worked! 
    I have 1 more question, how can I save a  pdf file into this created directory using the Extract Target Action?

    Tried "C:\\User\\Kapow\\"+date() + "\\sample.pdf"
    but it did not work.
    Could you advise on this? Thanks
    jking
    jking


    Posts : 103
    Points : 3863
    Join date : 2014-03-01
    Location : USA

    Create folder with its name as current date Empty Re: Create folder with its name as current date

    Post by jking Fri Dec 28, 2018 8:52 pm

    If you need to Write out a file, I would not use a Make Directory step, but rather a Write File Step.  

    You must specify:

    • File Name (Value, Variable, Expression or Converter).
    • File Content (the Variable to write out)
    • File Encoding (Default Unicode should work for pdf).
    • Append to File Checkbox.  Check this box if the file already exists and you want to add to the data in the file.  I use this if I am adding to an existing excel file.
    • Create Directories Checkbox.  Check this box if the Directory does not exist and you need to create a new directory on-the-fly.  If the directory does exist and you are adding a new File only you do not need to check this option.
    • Execute in Design Mode Checkbox.  Check this box if you want the Write File Step to execute from Design Mode.


    In your example below "C:\\User\\Kapow\\"+date() + "\\sample.pdf", you would use the Expression Option for the File Name, your pdf Variable for the File Content and check the Create Directories option.  That should do the trick.

    hth
    avatar
    junwei


    Posts : 16
    Points : 2057
    Join date : 2018-10-16

    Create folder with its name as current date Empty Re: Create folder with its name as current date

    Post by junwei Mon Dec 31, 2018 9:41 am

    Thanks for your help! Managed to solved it Very Happy

    However, I am stuck with specifying of the date format. Where can I input the date format that I want (day-month-year)? Is it in the Date variable or assign variable action. If so what is the date format, is it date(dd-MMMM-yyyy)? Thank you very much
    jking
    jking


    Posts : 103
    Points : 3863
    Join date : 2014-03-01
    Location : USA

    Create folder with its name as current date Empty Re: Create folder with its name as current date

    Post by jking Mon Dec 31, 2018 8:25 pm

    To format the date as dd-MMMM yyyy:
    Create a Short Text variable (for my example I will use ReportDate).
    Add an Assign Variable Step.  Variable is ReportDate
    Value: Change to Converter
    You will see "Get variable".  Click the minus button "-".
    Click the add button "+"
    Click Evaluate Expression
    type in date()
    Click the add button "+" → Date Handling → Extract Date
    Formats: click the add button "+" → Format Pattern 
    In Pattern: type yyyy-MM-dd
    Click OK
    Click the add button "+" → Date Handling → Format Date
    In Format Pattern enter dd-MMMM yyyy
    Test Input should show 2018-12-31 00:00:00.0
    Test Output should show 31-December 2018

    In your write file step, the expression would be "C:\\User\\Kapow\\"+ReportDate+"\\sample.pdf"
    Output would be C:\User\Kapow\31-December 2018\sample.pdf
    avatar
    junwei


    Posts : 16
    Points : 2057
    Join date : 2018-10-16

    Create folder with its name as current date Empty Re: Create folder with its name as current date

    Post by junwei Wed Jan 02, 2019 9:08 am

    Thank you very much for the help, Wishing you a Happy New Year!

    Sponsored content


    Create folder with its name as current date Empty Re: Create folder with its name as current date

    Post by Sponsored content


      Current date/time is Fri May 10, 2024 2:12 am