Windows 7 Forums
Welcome to Windows 7 Forums. Our forum is dedicated to helping you find support and solutions for any problems regarding your Windows 7 PC be it Dell, HP, Acer, Asus or a custom build. We also provide an extensive Windows 7 tutorial section that covers a wide range of tips and tricks.

Windows 7: Is there a Script or batch file that can create folders by date range

02 Jul 2012   #1

windows 7 32
Is there a Script or batch file that can create folders by date range

I was wondering if there was a way to create a set of folders in a specific directory according to a date range that i input.


Select start date 2011 10 01

select end date 2012 10 01

Select Output path of c:\users\XXXX\desktop\export data

and it creates a folder for all days from 2011 10 01 through 2012 10 01 and places them in the output path i have set for it.

any help would be greatly appreciated.

Thank you

My System SpecsSystem Spec
02 Jul 2012   #2

Windows 7 Pro x64 SP1

Welcome damjohnron to the windows 7 forums.

Here are some snippits of a dos batch file that will create a directory with the datek and tell you if it already exists.

set DATEST=%DATE:~10,4%%DATE:~4,2%%DATE:~7,2%
echo %datest%
rem if it looks ok, then you can press enter to continue
if exist %homepath%\documents\%datest% goto dup1
md %homepath%\documents\%datest%
rem the pause can be taken out if you wish.
go to end
rem you already have done this.

you can change the path statement to the directory you wish.

This batch file can be run each day that you want to create a new sub directory.
There are other ways to do this but a bit more complicated such as reading an external
text file for the directory names.

My System SpecsSystem Spec
02 Jul 2012   #3

windows 7 32

Thank you for your response on this.

i believe that i have not explained this sitaution correctly

the results that i would like to do is set a date range ie. 10/01/2011 - 10/01/2012
and have a folder created for every day in that date range.


I do apologize for any confusion on my description of this issue.

Thank you
My System SpecsSystem Spec

02 Jul 2012   #4

Windows 7 Pro x64 SP1

John, one problem with your requirements is that each month only goes to 28-29-30-31 so a counter would not work, Also the / marks won't work in a file or dir name.

you could create a text file with all the dates that you want and then read it, create a powershell script that will read the file and make the directory.
You might want to look into powershell which is in the accessories/powershell start panel.

I am sure that it is possible. I could do it in gwbasic pretty easily but I am not conversant in powershell.

My System SpecsSystem Spec
04 Jul 2012   #5

Windows 7 Pro x64

Try this, in Powershell.

$n = 0
$dest = Join-Path $env:USERPROFILE '\Desktop\Export Data'

$firstDate = '2011/10/01'
$lastDate = '2012/10/01'

While ( ( Get-Date $firstDate ).AddDays( $n ) -le ( Get-Date $lastDate ) ) {
    $path = Join-Path $dest ( Get-Date $firstDate ).AddDays( $n ).ToString( 'yyyy-MM-dd' )
    # REMOVE the "-WhatIf" in the line below to allow the directories to be created
    New-Item -Path $path -ItemType 'Directory' -WhatIf
My System SpecsSystem Spec

 Is there a Script or batch file that can create folders by date range

Thread Tools

Similar help and support threads
Thread Forum
i want to create a batch file to disable changing system time and date
hi, i want to create a batch file to disable changing system time and date hope some one will sure help me thank you
System Security
creating a batch script to create a scedualed task on multiple pc's
so im an IT specialist at a big car dealer ship im not that good with scripting but what i want to do is when i go around to a computer i want to be able to put a flash drive in run a batch script that creates a folder on the C drive transfers a few files (xml and .bat ) to that folder then from...
General Discussion
Creating a batch script or use a 3rdpartyprogram to create shortcuts
Hello! I'm having trouble creating a batch script to simply copy a shortcut to the desktop from a program installation, then carry out some tasks. Overall my goals are: Burn a CD that includes a autorun.inf that will load a batch script In the script I want it to activate two self...
General Discussion
File search (by date range) displays incorrect Mod Date in results
Searching for files modified in a specified date range (of the past 3 days) gets a search result list titled "date modified", and with the column heading "Date Modified" but the date listed against a file modified today is wrong. The date displayed matches the file creation date & is within the...
General Discussion
How to create a current date folder using batch file?
Hi I am using following batch file for cleaning the desktop and also for taking backup of desktop: @echo off set curr_date=%DATE:~10,4%-%DATE:~4,2%-%DATE:~7,2% mkdir "%USERPROFILE%\My Documents\backup\%curr_date%_backup"
General Discussion

Our Sites

Site Links

About Us

Find Us

Windows 7 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 7" and related materials are trademarks of Microsoft Corp.

Designer Media Ltd

All times are GMT -5. The time now is 15:20.
Twitter Facebook