Solved

Batch File

Posted on 2003-11-27
4
1,152 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
Comment Utility
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
Comment Utility
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
Comment Utility
-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_
Comment Utility
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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Suggested Solutions

Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
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 …
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

762 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

10 Experts available now in Live!

Get 1:1 Help Now