Della
Della

Reputation: 1634

Merging Multiple Commands in a Single Command with Argument

This question is a variation of this.

In my case, the command has an argument. For example, suppose I processing sample.tex with texlive, to generate a dvi, ps and pdf respectively. The commands will be

latex sample.tex
bibtex sample.aux
latex samlpe.tex
dvips sample.dvi
ps2pdf sample.ps 

Can I merge them together to a script file so that whenever I enter

makepdf sample.tex

all the above commands are executed sequentially, so that I get a pdf.

Upvotes: 0

Views: 389

Answers (2)

foxidrive
foxidrive

Reputation: 41287

This is the same as aacini's code but it also supports long filename elements.

@echo off
latex  "%~1"
bibtex "%~n1.aux"
latex  "%~1"
dvips  "%~n1.dvi"
ps2pdf "%~n1.ps"

If any of the commands are batch files then add a call keyword before the command name.

Upvotes: 0

Aacini
Aacini

Reputation: 67256

This file is makepdf.bat:

@echo off
latex %1
bibtex %~N1.aux
latex %1
dvips %~N1.dvi
ps2pdf %~N1.ps 

Execute it as you said before:

makepdf sample.tex

Upvotes: 1

Related Questions