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.


Create folder with its name as current date

Share

junwei

Posts : 15
Points : 115
Join date : 2018-10-16

Create folder with its name as current date

Post by junwei on 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.
avatar
jking

Posts : 66
Points : 1873
Join date : 2014-03-01
Location : USA

Re: Create folder with its name as current date

Post by jking on 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

junwei

Posts : 15
Points : 115
Join date : 2018-10-16

Re: Create folder with its name as current date

Post by junwei on 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
avatar
jking

Posts : 66
Points : 1873
Join date : 2014-03-01
Location : USA

Re: Create folder with its name as current date

Post by jking on 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

junwei

Posts : 15
Points : 115
Join date : 2018-10-16

Re: Create folder with its name as current date

Post by junwei on 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
avatar
jking

Posts : 66
Points : 1873
Join date : 2014-03-01
Location : USA

Re: Create folder with its name as current date

Post by jking on 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

junwei

Posts : 15
Points : 115
Join date : 2018-10-16

Re: Create folder with its name as current date

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

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

Sponsored content

Re: Create folder with its name as current date

Post by Sponsored content


    Current date/time is Wed Jan 16, 2019 10:19 pm