批量排除 *.lyx~ 文件 (windows)
exclude *.lyx~ files in batch (windows)
我刚刚创建了以下批处理文件,它将我所有的 lyx 文档保存为 tex 文件:
cd /d "D:\"
:: if the "for"-command is executed from the command line, just use "%" rather than "%%"
for /R %%g in (*.lyx) do "C:\Program Files (x86)\LyX 2.1\bin\lyx.exe" --force-overwrite --export pdflatex "%%g"
现在的问题是,批处理使用 *.lyx~ 文件而不是 *.lyx 文件,据我所知,这些文件是某种备份文件,不包含最新内容。
如何修改批处理文件,使其使用 *lyx 文件而不是 *.lyx~ 文件?
任何建议都会有很大帮助。
最佳 :-)
PS:如果我在命令行中输入这段代码(不使用批处理),一切都很好。
@Edit1:添加了 tokens
选项。现在它在带空格的子目录中工作。
将您的 for
循环修改为:
for /F "tokens=*" %%g in ('dir /b /s *.lyx') do if "%%~xg" equ ".lyx" (
"C:\Program Files (x86)\LyX 2.1\bin\lyx.exe" --force-overwrite --export pdflatex "%%g"
)
另一个解决方案是使用 forfiles.
至于第 3 条评论,我认为它同时做到了,但它在最后做到了 .lyx~。
要查看批处理文件的输出,只需从 cmd
window.
启动它
我刚刚创建了以下批处理文件,它将我所有的 lyx 文档保存为 tex 文件:
cd /d "D:\"
:: if the "for"-command is executed from the command line, just use "%" rather than "%%"
for /R %%g in (*.lyx) do "C:\Program Files (x86)\LyX 2.1\bin\lyx.exe" --force-overwrite --export pdflatex "%%g"
现在的问题是,批处理使用 *.lyx~ 文件而不是 *.lyx 文件,据我所知,这些文件是某种备份文件,不包含最新内容。
如何修改批处理文件,使其使用 *lyx 文件而不是 *.lyx~ 文件?
任何建议都会有很大帮助。
最佳 :-)
PS:如果我在命令行中输入这段代码(不使用批处理),一切都很好。
@Edit1:添加了 tokens
选项。现在它在带空格的子目录中工作。
将您的 for
循环修改为:
for /F "tokens=*" %%g in ('dir /b /s *.lyx') do if "%%~xg" equ ".lyx" (
"C:\Program Files (x86)\LyX 2.1\bin\lyx.exe" --force-overwrite --export pdflatex "%%g"
)
另一个解决方案是使用 forfiles.
至于第 3 条评论,我认为它同时做到了,但它在最后做到了 .lyx~。
要查看批处理文件的输出,只需从 cmd
window.