?
Solved

Is there a way to use a batch to create monthly folders "2014-02"

Posted on 2014-02-28
5
Medium Priority
?
665 Views
Last Modified: 2014-03-01
Currently, I create a monthly folder in all of our Customer's Folders. Ex: 2014-02 for February Reports.

I move all of the reports based on the Customer's Name into their folder using a batch.
Here is an example of the 2nd half of the move batch.

"\\companydirectory\abc\Reports\McDonalds\Standard Reports\2014-02"
"\\companydirectory\abc\Reports\Burger King\Standard Reports\2014-02"
"\\companydirectory\abc\Reports\Wendys\Standard Reports\2014-02"

Is there a way to have the system create the 2014-02, 2014-03, etc folders without manually going to each folder and creating one myself?
0
Comment
Question by:NNiicckk
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 13

Expert Comment

by:Santosh Gupta
ID: 39895680
hi,

use "MD %date:~-4,4%-%date:~4,2%" command to create the folder name by year-month format.
0
 
LVL 13

Expert Comment

by:Santosh Gupta
ID: 39895781
try this one..........
create-folder-date-bat.txt
0
 

Author Comment

by:NNiicckk
ID: 39896185
But is there a way to get a date folder created into each one of the Customer's folders without going to each folder manually?
0
 
LVL 43

Accepted Solution

by:
Steve Knight earned 2000 total points
ID: 39896215
Sure.  Try this for creating a specific one you enter.  Save it as "makedirs.cmd" or something.  It runs down everything in the basedir directory then goes one level further down under that in the "lowerdir" directory and creates the folder there.

Remove the word ECHO in captials to have it actually create the directories, at the moment it will show the MD commands on the screen to make sure you are happy first.

Steve

@echo off
Set basedir=\\companydirectory\abc\Reports
Set LowerDir=Standard Reports
Set /P Create=Enter directory to create: 
If "%create%"=="" exit /b

for /f "tokens=*" %%a in ('dir /b /ad "%basedir%"') do (
  echo Working on "%%~a"
  ECHO MD "%basedir\%%~a\%lowerdir%\%create%" 2>NUL
)

Open in new window

0
 
LVL 43

Expert Comment

by:Steve Knight
ID: 39896853
Thanks, hope that helps then.  You can combine that of course with getting the dat automatically too if wanted.

Steve
0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

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

This article was inspired by a question here at Experts Exchange (http://www.experts-exchange.com/Software/Photos_Graphics/Images_and_Photos/Q_28629170.html). The requirements stated in that question are (1) reduce the file size of a large number of…
Introduction: Recently, I got a requirement to zip all files individually with batch file script in Windows OS. I don't know much about scripting, but I searched Google and found a lot of examples and websites to complete my task. Finally, I was ab…
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses

650 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