?
Solved

Need some help with a batch file to creating sub-folders in a directory

Posted on 2014-08-28
3
Medium Priority
?
181 Views
Last Modified: 2014-09-02
Hello,

I have some reports that I save on a network share.  There is a report for every calendar date and I want each report in its own sub folder.  We'll be manually saving the reports to the share after download.  

Is there a way to create a batch file that would automatically create these sub-folders using the naming convention of "MMDDYY".  I am looking to avoid having my users manually create a new folder every day.


Thanks,
0
Comment
Question by:mike-9
3 Comments
 
LVL 5

Accepted Solution

by:
SemperPhi earned 1600 total points
ID: 40290253
Try this snippet, use what you need:
=================================================
@echo off
for /f "delims=" %%a in ('wmic OS Get localdatetime  ^| find "."') do set dt=%%a
set datestamp=%dt:~0,8%
set timestamp=%dt:~8,6%
set YYYY=%dt:~0,4%
set MM=%dt:~4,2%
set DD=%dt:~6,2%
set HH=%dt:~8,2%
set Min=%dt:~10,2%
set Sec=%dt:~12,2%

set stamp=%YYYY%-%MM%-%DD%_%HH%-%Min%-%Sec%
echo stamp: "%stamp%"
echo datestamp: "%datestamp%"
echo timestamp: "%timestamp%"

pause
0
 
LVL 26

Assisted Solution

by:Lionel MM
Lionel MM earned 400 total points
ID: 40292283
Do you want a daily batch file to run and create the folders for you so that each day the folders and sub folders are created on a server share or do you it created on each user's PC when they logon that day?
0
 

Author Comment

by:mike-9
ID: 40292308
I was looking for a daily or even monthly batch file to create the folders and sub folders on a server share.

I wound up finding a solution that worked for me.  It is simplistic.

I wound up just using excel to create the folder structure.  Column A was the MD command.  Column B was my folder.  Column C was a sub folder.  Column D was my date.  It was easy to drag down the column to get my consecutive dates.  I exported the whole thing as a text file and ran it as a batch.  

It's not completely automated but I could set up a decade of folders in a few minutes.  

I'm going to check out SemperPhi's solution just to increase my knowledge of the subject.
0

Featured Post

Prep for the ITIL® Foundation Certification Exam

December’s Course of the Month is now available! Enroll to learn ITIL® Foundation best practices for delivering IT services effectively and efficiently.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Log files are useful in diagnosing and repairing problems.  This is a list of common log files and their standard locations that I've compiled.   While this is not exhaustive, it is a pretty good list that I've found to be useful.  I may update it f…
Citrix XenApp, Internet Explorer 11 set to Enterprise Mode and using central hosted sites.xml file.
Windows 8 comes with a dramatically different user interface known as Metro. Notably missing from the new interface is a Start button and Start Menu. Many users do not like it, much preferring the interface of earlier versions — Windows 7, Windows X…
Windows 8 came with a dramatically different user interface known as Metro. Notably missing from that interface was a Start button and Start Menu. Microsoft responded to negative user feedback of the Metro interface, bringing back the Start button a…

864 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question