Solved

Batch File

Posted on 2003-11-27
4
1,159 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 101

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

Transaction Monitoring Vs. Real User Monitoring

Synthetic Transaction Monitoring Vs. Real User Monitoring: When To Use Each Approach? In this article, we will discuss two major monitoring approaches: Synthetic Transaction and Real User Monitoring.

Question has a verified solution.

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

A short article about problems I had with the new location API and permissions in Marshmallow
In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
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…
Starting up a Project

717 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