i am trying to create a batch file to run:
.tex --> .dvi : latex filename.tex
.dvi --> .ps : dvips -o filename.ps filename
.ps --> .pdf : ps2pdf filename.ps
I tried:
latex %1
dvips -o %~n%1.ps %n%1
ps2pdf %~n%1.ps
assuming that ~n
will give me the file name without the extension of a passed file. However, it doesn't work (apart from the first line). Does anyone know the correct version?
When echo is turned off, the command prompt doesn't appear in the Command Prompt window. To display the command prompt again, type echo on. To prevent all commands in a batch file (including the echo off command) from displaying on the screen, on the first line of the batch file type: Copy. @echo off.
Use double percent signs ( %% ) to carry out the for command within a batch file. Variables are case sensitive, and they must be represented with an alphabetical value such as %a, %b, or %c. ( <set> ) Required. Specifies one or more files, directories, or text strings, or a range of values on which to run the command.
The /P switch allows you to set the value of a variable to a line of input entered by the user. Displays the specified promptString before reading the line of input. The promptString can be empty.
The %~dp0 (that's a zero) variable when referenced within a Windows batch file will expand to the drive letter and path of that batch file. The variables %0-%9 refer to the command line parameters of the batch file. %1-%9 refer to command line arguments after the batch file name. %0 refers to the batch file itself.
Ok, some trial and error gave me
latex %1
dvips -o %~n1.ps %~n1
ps2pdf %~n1.ps
which does the trick
latex
and dvips
.ps2pdf
needs the extension.rem this is a batch file, named mybatch.bat
rem it takes a filename without extension
echo off
latex %1
dvips %1
ps2pdf %1.ps
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With