WinAutomation - windows automation software with macro recorder
About Softomotive

      Create Folders based on Year>Month>Day for a specific period of time

       Imagine having to create a folder for each day of the year for any random use, that could be to save the day’s work or even to save your projects or photos per day or just to keep track of the your work you have been doing per day throughout the whole year.

       
      Do you sit there and create folders one by one? It’ll probably take you a couple of hours to create 365 folders for each day and another 12 folders per month. And you will also have to make sure you get the right number of days for each month.. cause not all months have 30 days and depending on the year February does not always have 28 days.
       
      The best thing to do is run a job that will create a folder for the period of time we want, according to the year, month and day.
       
      Action 1. We start by setting the folder in which our new folders will be created. We will use the Display Select Folder Dialog and store the selected folder in the %ParentFolder% variable for later use. 
       
       
      Action 2. We then need to get the range of dates we will be creating the folders for, so we use the Display Select Date Dialog to prompt the user to input a date range. We only need the date so we will prompt for date only. We store the First selected date into %StartDate% and the second selected date into %FinishDate%. 
       
      We will be using the Loop Condition Action to create a folder for each year, month and day within our range of dates, but in order to do that we first need to set a variable that will increase by 1 day each time the loop runs to get to the next day in the loop having started from day 1, which is our %StartDate%.
      To achieve that, we will set our %CurrentDate% to be equal to our %StartDate%to start with, so that all our actions from now on will be processed according to the %CurrentDate%, and each time our loop runs at the end of the loop we will be adding a day to the %CurrentDate% till the %CurrentDate% is smaller or equal to the %FinishDate% where our loop will end.
       
      To make things less complicated:
      Action 3. We will use the Set Variable action and set the %CurrentDate% to be equal to the %StartDate%. 
       
      Action 4. Using the Loop Condition Action we create a loop that will repeat all the actions within the loop block as long as the CurrentDate is smaller or equal to the FinishDate. %CurrentDate% <= %FinishDate% 
       
       
      Within our loop we will include:
      Action 5. We shall create a folder (within the parent folder we previously set), named after the %CurrentDate.Year% .
       
      For each DateTime Value you can get the Date and Time not only as a total, but you can also get specific details individually. For example:
      If the current Date and Time were 25/5/2010 2:49 PM you could then get:
      The current Day using: %CurrentDate.Day% which would display the number 25
      The current Month using: %CurrentDate.Month% which would display the number 5
      The current Year using: %CurrentDate.Year% which would display the number 2010
      Same applies for the current day of the year, day of the week, hour, minutes, seconds, etc.   
       
      Actions 6, 7. Since we want to name our folders in a sortable way and we also want to have not only the numerical value of the month, but also the name of each month displayed, we will use the "ConvertDateTime to Text" action to convert the %CurrentDate% to text using the “MM – MMMM” custom format (that would display for example “05 - May”). The resulting text will then be stored into the %CurrentMonth% variable to be used in Action 7. This action will create a folder within the %YearFolder% folder we previously created, named %CurrentMonth% and store the newly created folder into %MonthFolder% . 
       
       
      After the first loop, each time the loop runs, actions 5 and 6 (that create the year's folder and month's folder respectively) will also be repeated, but since the folders already exist, the job will just ignore these 2 actions and continue to the next until the month (or the year) changes. In this case it will create the new month’s folder and after that for each day in our new month the action will be ignored.
       
      Action 8. We shall then use the Create Folder action again and create a folder in the %MonthFolder% named after the %CurrentDate.Day%. As you see I will not store the variable of the newly created folder that represents the CurrentDay since I will not be using it in any later action. But you may just leave it to the default value if you wish to do so. 
       
       
      Before we end our loop, since we have finished with creating all the folders needed for the current date, we need to get on with the following day, and that we will do as previously mentioned by using the Add to DateTime Action to add a day to the %CurrentDate%.
       
      So if for example my loop started on May the 5th 2010 and was to end on the 11th of May, at the end of the first repetition we would need to add a day to the current date so that the next time the loop runs the current date is no longer the 5th but the 6th of May and it would have to repeat the same actions till the current date is the 12th where the 12th is not equal or smaller from the %FinishDate% which means that our loop would come to an end.. 
       
       
      EXTENDING OUR JOB 
       
      We can also make a few changes to customize this job, as for example within the parent folder, we could create a folder that would be named after the range of dates that the folder contains.
       
      That we can achieve by Converting the %StartDate% and the %FinishDate% to text and then use the create folder action to create a folder named using the range of dates by typing into the New Folder Name Field: “From %FormatedStartDate% To %FormatedFinishDate%” and store it into the variable %ParentFolder%. That way you still get to select the folder in which you will be creating the new folders, but you also get to specify the range you use. 
        
       
       

       

      AttachmentSize
      012_Create a folder for every day for a specific period categorize by month.waj16 KB
      012_Create a folder for every day for a specific period categorize by month-EXT.waj17 KB
      No votes yet

      Comments:
      #1 by Samantha - Fri, 05/28/2010 - 19:49

      I'm glad you enjoyed it Peter :)


      #2 by peter- - Thu, 05/27/2010 - 15:43

      Nice post once again Samantha thank you



      Post new comment

      The content of this field is kept private and will not be shown publicly.
      • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <img> <p>
      • Lines and paragraphs break automatically.
      • Web page addresses and e-mail addresses turn into links automatically.
      • You may quote other posts using [quote] tags.

      CAPTCHA
      This question is for testing whether you are a human visitor and to prevent automated spam submissions.

      Featured Clients




      Monthly Blog Archive