2011-10-05 15 views
2

我寫了一個批處理文件,用於創建包含乳膠文件中縮寫和引用的文件。它工作得很好。我使用記事本++運行菜單中的這個。我的問題是,我必須每次更改批處理文件中的文件名。我想創建一個可以與任何文件一起使用的通用文件。用於pdflatex-makeindex-bibtex的批處理腳本,適用於記事本++中的當前文件

這裏是我的工作腳本

:: 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 

,這裏是我的嘗試

:: 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 

但你可以看到有一個與中文提供和makeindex.exe命令行,因爲擴展的挑戰不應該提供給bibtex,所以在記事本++中引用當前打開的文件的%2將無法工作。我也不知道如何指定全局的.nlo和.nls,以便mnakeindex可以找到與tex文件名相對應的正確文件名。

我正在通過記事本++批量執行此操作,因爲我未能使用textworks生成命名法!

感謝所有幫助

事實證明,更換的thesis所有發生率在批處理文件%2實際工作。我想我問得太早,但如果有人在這裏有一個類似的問題是解決方案:

:: 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 
+2

請將您的解決方案作爲*答案*發佈到您的問題中,而不是將其包含在問題中。 –

+0

一些評論。您可以將前兩個命令改爲「PUSHD%1」。而且,在'START'和':cleanup'之前,我認爲'GOTO:eof'缺失;除非你想再次運行清理,在這種情況下,我會添加第二個'CALL:cleanup'和'GOTO:eof'。 –

回答

0
:: 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 
0

我知道你已經有了解決方案,但還有另一種方式。

只需使用命令「basename」刪除結尾。

包含在批處理文件行

filebase=$(basename $2 .pdf) 

,然後「filebase」將「論文」就算你給輸入「thesis.pdf」(替換$2如適用)。

相關問題