How do I create a batch file?

Tommy B

Registered User.
Local time
Today, 05:46
Joined
Feb 26, 2001
Messages
43
Hi Guys,

Here's my problem...well the IT related one anyway :D

I have 10 text files that I want to append into one file before I import into my database.

I think a batch file is the best option for achieving this, so how do I create one?

I know this is a bit wide of the mark in terms of access but I'm hoping someone will have done this before :p

Thanks All,

Tommy B
 
Sorry I can't help you with the batch file, but I intreuged as to why you would want to do that anyway?

Surely when you bring it in to Access it will be appended anyway?
 
There might be some way to do this using some DOS commands, but I also ask why would you want to? Let Access do it for you.
 
if you really want to make a crappy DOS batch file its simple:

batchbat:
@echo off

TYPE FILE1 >>NEWFILE
TYPE FILE2 >>NEWFILE
TYPE FILE3 >>NEWFILE

etc etc
 
Cheers for the replies guys. I'd rather just write code to import one file than ten. That's my reasoning :rolleyes:

Tommy B
 
TommyB, ever heard of a loop? Or copy and paste?
 
1) Open Notepad
2) type proper syntax for DOS command
3) Save file with extension .bat
4) Embed in your Access code

Private Sub Command1_Click()

Dim retval
retval=Shell("c:\test.bat",vbMinimizeFocus)

End Sub
 
Thanks IgorB that was just the info I was after :D

Cheers,

Tommy B :cool:
 
A word of caution..
The code in your vb module will continue to execute regardless of whether or not the batch file has completed. You can combat this problem by putting a "copy /y" statement at the end of your batch file.
Now in your vb code module, use a while...wend loop to continually check for the existence of the "dummy" file being copied by your batch file. This way, your vb module will pause until it recieves the okay from the batch file.

Code:
  Dim retval 
  if Dir("C:\ProjectDirectory\Done.txt") then Kill    ("C:\ProjectDirectory\Done.txt")  'kill file if its there from last time
retval=Shell("c:\test.bat",vbMinimizeFocus) 
while
not Dir("C:\ProjectDirectory\Done.txt")
wend  'loop until the file has been copied

Create a text file and name it C:\ProjectDirectory\NotDone.txt
Now in your batch file add this line to the end...
Copy /y C:\ProjectDirectory\NotDone.txt C:\ProjectDirectory\Done.txt
 
Hi Sambo,

Thanks for pointing this out...as I'm a newbie this would never have occured to me:o

I'm having trouble writing my batch file anyway, can you give me any help? I know it should be simple but I just can't seem to get the syntax right...have been searching the net for a giude or FAQ on how write one but so have drawn a blank....any help you can give is greatly appreciated :p

Hope everyone has a great weekend!

Tommy B
 
Okay I got it to work...was a problem with my SOE work machine....wouldn't let me run a batch!!!

Thanks for all the help guys :D

Tommy B
 

Users who are viewing this thread

Back
Top Bottom