Solved

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

Posted on 2014-02-28
5
515 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
  • 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 500 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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Issue with cURL on Windows 7 92
How to copu batch file to a network location 62 82
Batch/VBscript: import massively chedule task in windows task scheduler 15 44
batch script 3 37
When you receive another warning that your shared drive is almost full and you have asked your users to clean out old files again and again, here is a single command that may help. This command will place all the files that have not been used rec…
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…
In a recent question (https://www.experts-exchange.com/questions/28997919/Pagination-in-Adobe-Acrobat.html) here at Experts Exchange, a member asked how to add page numbers to a PDF file using Adobe Acrobat XI Pro. This short video Micro Tutorial sh…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

813 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now