Register to reply

Creating Batch Files

by Pauly Man
Tags: batch, creating, files
Share this thread:
Pauly Man
#1
Nov12-03, 08:05 PM
P: 127
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:

@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:
C:\Temp\
Then the batch file writes to the prompt:
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?
Phys.Org News Partner Science news on Phys.org
Scientists develop 'electronic nose' for rapid detection of C. diff infection
Why plants in the office make us more productive
Tesla Motors dealing as states play factory poker
dduardo
#2
Nov12-03, 08:34 PM
Emeritus
dduardo's Avatar
P: 1,919
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.
Pauly Man
#3
Nov12-03, 09:24 PM
P: 127
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.

NateTG
#4
Nov12-03, 09:31 PM
Sci Advisor
HW Helper
P: 2,537
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.
Pauly Man
#5
Nov12-03, 09:41 PM
P: 127
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.
Pauly Man
#6
Nov13-03, 09:38 PM
P: 127
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?
NateTG
#7
Nov13-03, 10:20 PM
Sci Advisor
HW Helper
P: 2,537
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.
Pauly Man
#8
Nov15-03, 08:31 PM
P: 127
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?
NateTG
#9
Nov16-03, 12:04 AM
Sci Advisor
HW Helper
P: 2,537
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.
Pauly Man
#10
Nov16-03, 01:39 AM
P: 127
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.
Pauly Man
#11
Nov16-03, 01:59 AM
P: 127
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.


Register to reply

Related Discussions
Batch file Computing & Technology 2
Matlab and Batch mode Math & Science Software 2
Batch distillation Materials & Chemical Engineering 3
Creating PDF Files from Other Formats Computing & Technology 10
More batch files Computing & Technology 0