Osley
asked on
Batch folder creation?
I need to:
1. create three folders eg. Folder 1, 2 and 3 within a folder, where there's 200 folders - all folders within this folder, will need the folders 1,2 and 3 created
2. create a log file confirming success/ failure
I've been playing around with the following command via a DOS batch script:
@echo on
H:
cd H:\
echo Making Directories...
mkdir %1\
What's the simplest/ best technique for doing this - DOS or VB Script? I think VB Script would be the best?
Does anyone have a script that can perform this function?
1. create three folders eg. Folder 1, 2 and 3 within a folder, where there's 200 folders - all folders within this folder, will need the folders 1,2 and 3 created
2. create a log file confirming success/ failure
I've been playing around with the following command via a DOS batch script:
@echo on
H:
cd H:\
echo Making Directories...
mkdir %1\
What's the simplest/ best technique for doing this - DOS or VB Script? I think VB Script would be the best?
Does anyone have a script that can perform this function?
ASKER
Hi. Thanks for the fast response.
I need to ammend the directory from:
set BaseDir=H: to a folder in H, which is H:\Temp Folder\2013. What's the proper syntax? I've added this to the end of BaseDir=H: and one folder was created on the desktop with the three folders contained within.
The log file generated the following:
Making Directories...
C:\Users\Administrator\Des ktop>(for %B in ("Excel" "Powerpoint" "Word") do (md "H:\Temp\%~B" 1>NUL 2>&1 && (echo Created: "H:\Temp\%~B" ) || (echo *ERROR*: "H:\Temp\%~B" ) ) )
I need to ammend the directory from:
set BaseDir=H: to a folder in H, which is H:\Temp Folder\2013. What's the proper syntax? I've added this to the end of BaseDir=H: and one folder was created on the desktop with the three folders contained within.
The log file generated the following:
Making Directories...
C:\Users\Administrator\Des
This should handle that.
@echo off
setlocal
set BaseDir=H:\Temp Folder\2013
set NewDirs="Excel","Powerpoint","Word"
(
echo Making Directories...
for /D %%A in ("%BaseDir%\*.*") do (
for %%B in (%NewDirs%) do (
md "%%~A\%%~B" >NUL 2>&1 && (
echo Created: "%%~A\%%~B"
) || (
echo *ERROR*: "%%~A\%%~B"
)
)
)
)>"log.txt"
~bp
ASKER
I've updated the field and encounter the error:
1. A 'home' folder is created on the desktop, with the 3 folders within
2. The log file is as follows:
C:\Users\Administrator\Des ktop>(for %B in ("Excel" "Powerpoint" "Word") do (md "H:\Staff\%~B" 1>NUL 2>&1 && (echo Created: "H:\Staff\%~B" ) || (echo *ERROR*: "H:\Staff\%~B" ) ) )
I updated the field with the following:
set BaseDir=H:\Staff Home Folder\2013
The above is the actual directory path..
Thanks again.
1. A 'home' folder is created on the desktop, with the 3 folders within
2. The log file is as follows:
C:\Users\Administrator\Des
I updated the field with the following:
set BaseDir=H:\Staff Home Folder\2013
The above is the actual directory path..
Thanks again.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Perfect!
Thanks for the script - I should've looked closer at the code update you provided.
Thanks. Much appreciated.
Thanks for the script - I should've looked closer at the code update you provided.
Thanks. Much appreciated.
ASKER
I've requested that this question be closed as follows:
Accepted answer: 0 points for Osley's comment #a38812880
for the following reason:
Script performed exactly as desired.
Accepted answer: 0 points for Osley's comment #a38812880
for the following reason:
Script performed exactly as desired.
Did you mean to close the question this way. Normally I would have expected you to select my last script post as the solution and award points?
~bp
~bp
ASKER
Apologies. I didn't mean to select it that way...
Thanks for the solution. It's saved loads of time.
Thanks for the solution. It's saved loads of time.
ASKER
Solution worked as requested. Saved loads of time because of it.
Welcome, glad that was useful, and thanks for the feedback.
~bp
~bp
ASKER
Hi billprew. One more question - I need to modify the script, so that it creates one folder called 'documents' and with this folder, 3 more folders.
Apologies -
Apologies -
I posted that in the related question.
~bp
~bp
Open in new window
~bp