Create a .bat file. (1 Viewer)

LaBam

Registered User.
Local time
Today, 07:39
Joined
Mar 21, 2002
Messages
48
I use the following MS DOS command to convert, append and rename all .t files in the C:\Bam folder to a .txt file named Kotor.txt It works perfectly.

C:\Bam> for %1 in (*.t) do type %1 >> Kotor.txt

My problem now is to create a .bat file that will do precisely this. That is, on calling the .bat file, it should go to the Bam folder on my C:\ and convert all the .t files to .txt and compress them all to one file called say Kotor.txt

I'd be grateful for any suggestions.
 

ghudson

Registered User.
Local time
Today, 02:39
Joined
Jun 8, 2002
Messages
6,195
You should be able to call the batch file if your DOS command works. Just put your DOS command in a batch file and then call that batch file from Access.

Call Shell("c:\test.bat", vbNormalFocus)

Ensure that your batch file ends with the "Exit" command so that it closes DOS when the batch file is done.

HTH
 

LaBam

Registered User.
Local time
Today, 07:39
Joined
Mar 21, 2002
Messages
48
Sorry if didn't make myself clear but what I really wanted to know is how the .bat file will look like. This is what i wrote and saved as a bat file but didn't seem to work.

**************************************
C:
cd Bam
for %1 in (*.doc) do type %1 >> Kotor.txt
Exit

**************************************

Any suggestions?
 

ghudson

Registered User.
Local time
Today, 02:39
Joined
Jun 8, 2002
Messages
6,195
I am confused. I thought you stated your MS DOS command works perfectly.

I use the following MS DOS command to convert, append and rename all .t files in the C:\Bam folder to a .txt file named Kotor.txt It works perfectly.

C:\Bam> for %1 in (*.t) do type %1 >> Kotor.txt
Are you able to use this command to your liking?
C:\Bam> for %1 in (*.t) do type %1 >> Kotor.txt
But not in a batch file? Are you running this command from the Run prompt? Start / Run...
 

LaBam

Registered User.
Local time
Today, 07:39
Joined
Mar 21, 2002
Messages
48
Yes, I use this MS DOs command to my liking in DOS but can't get it to work in a bat file. I tried double-clicking it and then running it from the Start/Run... button but stll no luck. So I figured maybe I didn't write the bat file correct.
 

rpadams

Registered User.
Local time
Today, 02:39
Joined
Jun 17, 2001
Messages
111
Make sure you create your .bat with a simple text editor, no formatting. Also try adding a CTRL-Z at the end of the .bat file before you save it.
 

LaBam

Registered User.
Local time
Today, 07:39
Joined
Mar 21, 2002
Messages
48
Finally got it to work. The problem was that to use the FOR command in a batch program, one must specify the %%variable instead of a %variable. So my final .bat file was as follows:

**************************************
C:
cd\
cd Bam
for %%1 in (*.doc) do type %%1 >> Kotor.txt
Exit
**************************************

I hope this helps someone in the future.
 

Users who are viewing this thread

Top Bottom