Creating Batch Files to Automate DVI-PDF File Creation

In summary, the user is trying to create a batch file to automate the process of creating dvi and pdf files from tex files. The batch file asks the user for the name of the file, the type of file to be created, and the input tex file. The batch file then opens the command prompt and writes the input tex file to the output.
  • #1
Pauly Man
129
0
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?
 
Computer science news on Phys.org
  • #3
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.
 
  • #4
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.
 
  • #5
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.
 
  • #6
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?
 
  • #7
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.
 
  • #8
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?
 
  • #9
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.
 
  • #10
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.
 
  • #11
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.
 

1. How do I create a batch file to automate DVI-PDF file creation?

To create a batch file for automating DVI-PDF file creation, you will need to use a text editor such as Notepad. Start by opening Notepad and writing the commands you want to use for the automation process. Once you have written the commands, save the file with a .bat extension. You can now run the batch file by double-clicking on it.

2. What commands can I use in a batch file for automating DVI-PDF file creation?

There are various commands that you can use in a batch file for automating DVI-PDF file creation, such as "latex" for compiling the DVI file, "dvipdf" for converting the DVI file to PDF format, and "del" for deleting unnecessary files. You can also use conditional statements and loops to make the process more efficient.

3. Can I customize the batch file to fit my specific needs?

Yes, you can customize the batch file to fit your specific needs. Batch files allow for flexibility and can be tailored to suit your requirements. You can add or remove commands, change the order of execution, and even include user input for more control over the automation process.

4. How can I run the batch file automatically at a specific time?

To run the batch file automatically at a specific time, you can use the Windows Task Scheduler. Open the Task Scheduler and create a new task. In the "Actions" tab, select "Start a program" and choose your batch file as the program to run. You can then set the frequency and time for the task to run.

5. Can I use a batch file to automate DVI-PDF file creation on a Mac or Linux?

Yes, batch files can be used on Mac and Linux systems as well. However, the commands and syntax may be different compared to Windows. You can use the terminal or shell to create and run the batch file, or you can use a scripting language like Bash or Python to achieve the same automation process.

Similar threads

  • Programming and Computer Science
Replies
3
Views
2K
  • Programming and Computer Science
Replies
10
Views
4K
  • Programming and Computer Science
Replies
2
Views
1K
  • Computing and Technology
Replies
6
Views
3K
  • Programming and Computer Science
Replies
11
Views
1K
  • Programming and Computer Science
Replies
1
Views
1K
  • Programming and Computer Science
Replies
4
Views
5K
  • Programming and Computer Science
Replies
8
Views
6K
  • Programming and Computer Science
Replies
2
Views
2K
  • Programming and Computer Science
3
Replies
75
Views
4K
Back
Top