## Creating Batch Files

Hi guys,

I am trying to create a batch file to help automate me creating dvi and pdf files from tex files. I'm in a windows xp environment. I have set up a batch file that asks the user whether they want to create a pdf file or a dvi file for output and then opens the command line editor:

Code:
@echo off
@title Create dvi-pdf Files
@set /p type=dvi or pdf?:
@cls
echo Type: texify --clear --src [Filename]
@%SystemRoot%\system32\cmd.exe
At present I'm not doing anything with the information the user has given me, but I will. At present I just want to know how to add information to the prompt. At present all it does is open up the command prompt to the current directory, I want it to then write information to the prompt and execute it. Like so:

The command prompt opens like I said:
Code:
C:\Temp\
Then the batch file writes to the prompt:
Code:
C:\Temp\texify --clear --src Temp.tex
Which will then convert the tex file into a dvi file and clear all the other files such as the aux file and log file. How do I get the batch file to write to the prompt?
 PhysOrg.com science news on PhysOrg.com >> New language discovery reveals linguistic insights>> US official: Solar plane to help ground energy use (Update)>> Four microphones, computer algorithm enough to produce 3-D model of simple, convex room
 Recognitions: Staff Emeritus Try this - http://www.microsoft.com/technet/tre...docs/batch.asp I haven't written batch files for windows in the longest time. Linux command shells are definitely a lot more powerfull.
 Thanx dduardo, I had already found that link though. I have made progress. The batch file asks the user for the name of the file and whether they want pdf or dvi putput, then they are taken to the command prompt witht the current path displayed, all they then have to do is type in the variable name for the output and away it goes! It's actually more labour intensive to run the batch file than to typw it in directly. But I know this will work eventuially. I have put a link to the batch file in the context menu for any tex file, so that is good. However it makes asking for the filename stupid really, but I can't work out how to let the batch file know which file they clicked on. I still can't get the batch file to automatically run the thing either, it seems silly that I have to type a variable name into the command promt to run it.

Recognitions:
Homework Help

## Creating Batch Files

I'm not sure about windows, but you could try
cmd32.exe %foo
where foo is the variable you want to use.

If you want to execute a command, just have the batch file call it directly.
 I just discovered the pipe command "|" which uses the output of one command as the iput of another. Just what I needed to make the batch file work automatically once I've given it data. =] So now all I do is input the file name and output type, and away it goes. Now all I need to do is work out how I can find out the filename automatically, after all I am clicking the context menu of a particlular file.
 Well, I can't work out how to find the identity of the file that was clicked. I know there must be a way, but I can't seee it yet. Anyone have any ideas at all?

Recognitions:
Homework Help
 Originally posted by Pauly Man Well, I can't work out how to find the identity of the file that was clicked. I know there must be a way, but I can't seee it yet. Anyone have any ideas at all?
You can set the filename to be passed as an argument as part of the default action as part of the set up in file types.

 Originally posted by NateTG You can set the filename to be passed as an argument as part of the default action as part of the set up in file types.
Okay, that half works. It correctly passes the filename to the batch file, the problem is that it sends the entire path, eg.

"C:\My Documents\Test.tex"

I want it simply to send "Test.tex" as the filename. Can I force the DDE to send only the local filename? Or if not is there a way to have the batch file erase the earlier path, which I know in advance because I keep all my tex files in the one directory?
 Recognitions: Homework Help Science Advisor I'm not sure. If you were using Unix, I'd recommend having the script strip out the pathname using sed or perl. You can probably do something similar.
 Yeah, I'm starting to see the benefits of linux. I always new it was useful, as we use it at uni. But now I'm seeing the beneifts for everyday use as well. I'm sure there us a way to write up a simple c++ exe or dll to take the file type and append it as necessary, just need to work out how to send the info in the batch file to the exe and then back to the batch file.
 Okay, problem completely solved. [:))] I found some new commands I didn't know about, that allow you to pick out the useful bits of the file path.

 Similar discussions for: Creating Batch Files Thread Forum Replies Computing & Technology 2 Math & Science Software 2 Materials & Chemical Engineering 3 Computing & Technology 10 Computing & Technology 0