Solved

Batch File

Posted on 2003-11-27
4
1,155 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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

This article will show, step by step, how to integrate R code into a R Sweave document
If you’re thinking to yourself “That description sounds a lot like two people doing the work that one could accomplish,” you’re not alone.
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

791 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