Solved

Batch File

Posted on 2003-11-27
4
1,156 Views
Last Modified: 2011-10-03
I have the following code

@echo off

set /p dirname="Enter Folder Name: "
md t:\"69 to 74"\%dirname%\Correspondance\Client
md t:\"69 to 74"\%dirname%\Correspondance\"Patent Office"
md t:\"69 to 74"\%dirname%\Other\"Prior Art"
md t:\"69 to 74"\%dirname%\Specification\Drafts
md t:\"69 to 74"\%dirname%\Specification\Drawing
md t:\"69 to 74"\%dirname%\Specification\Finals
set  dirname=

I have a database with file numbers.  Is there someway for me to pull the folder name from a list ..whether it be a csv or from a table?  If not can anyone offer help with another script that will do the same?

thanks
0
Comment
Question by:rcolombi
  • 2
4 Comments
 
LVL 100

Expert Comment

by:mlmcc
ID: 9833969
You could do it from VB or another language.  You could write a program to build the batch file for you then execute it.

mlmcc
0
 
LVL 4

Accepted Solution

by:
1mak earned 250 total points
ID: 9834175
You can do it with a text file containing the folder(s) names, and a second batch file that does the actual creation of directories (and whatever else you want to do).

first batch file (createAll.bat)
-----------------------------------------------------------------------------------------------
    FOR /F "eol=; delims== " %%i in (DestFolders.txt) do doStuff.bat %%i
-----------------------------------------------------------------------------------------------

second batch file (doStuff.bat)
-----------------------------------------------------------------------------------------------
    echo - Creating t:\"69 to 74"\%1\Specification\Drawings
    echo - Creating t:\"69 to 74"\%1\Specification\Finals
-----------------------------------------------------------------------------------------------

folders list file (DestFolders.txt) - lines starting with semicolon are ignored
-----------------------------------------------------------------------------------------------
; List of folders to create
Folder1
Folder2
-----------------------------------------------------------------------------------------------

Obviously, the lines made up entirely of dashes shouldn't be copied into files...

Hopefully this is what you're looking for?

0
 
LVL 4

Expert Comment

by:1mak
ID: 9834189
-Addendum to Last Post-

the for loop which goes thru the entries ignores any lines that start with ";" (that's the "eol=;" part), and the "delim==" is irrelevant (mistaken cut&paste!). So, you can use:
    FOR /F "eol=;" %%i in (DestFolders.txt) do doStuff.bat %%i

If you don't even perceive any benefits of having comments in the folder list file then:
    FOR /F %%i in (DestFolder.txt) do doStuff.bat %%i

Hope this helps...
0
 
LVL 16

Expert Comment

by:_nn_
ID: 9835682
Assuming a CSV file of the form:

"columName1","columnName2", (...), "columnNameN"
"data1","data2",(...), "dataN"

Assuming the directory name is in say the 4th column of 8, I would do something like this :

@echo off

for /f "skip=1 tokens=1-8 delims=," %%a in (SomeFile.csv) do call :do_it %%d
goto end

:do_it
set dirname=%1
md t:\"69 to 74"\%dirname%\Correspondance\Client
md t:\"69 to 74"\%dirname%\Correspondance\"Patent Office"
md t:\"69 to 74"\%dirname%\Other\"Prior Art"
md t:\"69 to 74"\%dirname%\Specification\Drafts
md t:\"69 to 74"\%dirname%\Specification\Drawing
md t:\"69 to 74"\%dirname%\Specification\Finals
set  dirname=

:end
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

Suggested Solutions

Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Although it can be difficult to imagine, someday your child will have a career of his or her own. He or she will likely start a family, buy a home and start having their own children. So, while being a kid is still extremely important, it’s also …

733 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