Solved

Batch File

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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

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…
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.
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

810 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