Search code examples
batch-filelatexnotepad++bibtex

batch script for pdflatex-makeindex-bibtex that works on current file in notepad++


I have written a batch file that I use to create a file containing abbreviations and references from a latex file. It works very well. I use this from within notepad++ Run menu. My problem is that I have to change the filename from within the batch file every time. I would like to create a universal file that can work with any file.

here is my working script

:: Called from Notepad++ Run
:: [path_to_bat_file] "$(CURRENT_DIRECTORY)" "$(NAME_PART)"

:: Change Drive and  to File Directory
%~d1
cd %1

:: Run Cleanup
call:cleanup
tskill acrobat  
pdflatex thesis.tex
bibtex thesis
pdflatex thesis.tex
pdflatex thesis.tex
makeindex.exe thesis.nlo -s nomencl.ist -o thesis.nls
pdflatex thesis.tex
START "" thesis.pdf

:cleanup
:: del *.log
del *.dvi
del *.aux
del *.bbl
del *.blg
del *.brf
del *.out
goto:eof

and here is my attempt

:: Called from Notepad++ Run
:: [path_to_bat_file] "$(CURRENT_DIRECTORY)" "$(NAME_PART)"

:: Change Drive and  to File Directory
%~d1
cd %1

:: Run Cleanup
call:cleanup
tskill acrobat  
pdflatex %2
bibtex thesis
pdflatex %2
pdflatex %2
makeindex.exe thesis.nlo -s nomencl.ist -o thesis.nls
pdflatex %2
START "" %2.pdf

:cleanup
:: del *.log
del *.dvi
del *.aux
del *.bbl
del *.blg
del *.brf
del *.out
goto:eof

but as you can see there is a challenge with the bibtex and the makeindex.exe command lines because an extension is not supposed to be provided to the bibtex and so the %2 which refers to the current opened file in notepad ++ wont work. I also dont know how to specify global .nlo and .nls so that mnakeindex can find the right filenames corresponding to the tex filename.

I am doing this by batch from notepad++ because i failed to generate nomenclature using textworks!!

Thanks for any help

It turns out that replacing all the incidences of thesis in the batch file to %2 actually works. I guess i asked too early but if anyone has a similar problem here is the solution:

:: Called from Notepad++ Run
:: [path_to_bat_file] "$(CURRENT_DIRECTORY)" "$(NAME_PART)"

:: Change Drive and  to File Directory
%~d1
cd %1

:: Run Cleanup
call:cleanup
tskill acrobat  
pdflatex %2.tex
bibtex %2
pdflatex %2.tex
pdflatex %2.tex
makeindex.exe %2.nlo -s nomencl.ist -o %2.nls
pdflatex %2.tex
START "" %2.pdf

:cleanup
:: del *.log
del *.dvi
del *.aux
del *.bbl
del *.blg
del *.brf
del *.out
goto:eof

Solution

  • :: Called from Notepad++ Run
    :: [path_to_bat_file] "$(CURRENT_DIRECTORY)" "$(NAME_PART)"
    
    :: Change Drive and  to File Directory
    PUSHD %1
    
    :: Run Cleanup
    call:cleanup
    tskill acrobat  
    pdflatex %2.tex
    bibtex %2
    pdflatex %2.tex
    pdflatex %2.tex
    makeindex.exe %2.nlo -s nomencl.ist -o %2.nls
    pdflatex %2.tex
    START "" %2.pdf
    call:cleanup
    goto:eof
    
    :cleanup
    :: del *.log
    del *.dvi
    del *.aux
    del *.bbl
    del *.blg
    del *.brf
    del *.out
    goto:eof