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

NNiicckk
NNiicckk used Ask the Experts™
on
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?
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Top Expert 2014

Commented:
hi,

use "MD %date:~-4,4%-%date:~4,2%" command to create the folder name by year-month format.
Top Expert 2014

Commented:
try this one..........
create-folder-date-bat.txt

Author

Commented:
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?
Commented:
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

Commented:
Thanks, hope that helps then.  You can combine that of course with getting the dat automatically too if wanted.

Steve

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial