windows 使用批处理文件打开多个 PDF 文档

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/695603/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-09 06:12:40  来源:igfitidea点击:

Opening multiple PDF documents using batch file

windowsbatch-filepdfcmdacrobat

提问by Assaf Lavie

I am trying to open several PDF documents using a simple batch file:

我正在尝试使用一个简单的批处理文件打开多个 PDF 文档:

ECHO OFF
CLS
cd Program Files\Adobe\Reader 9.0\Reader
Acrord32.exe C:\Users\BW1.pdf
Acrord32.exe C:\Users\BW2.pdf
Acrord32.exe C:\Users\BW3.pdf
Acrord32.exe C:\Users\BW4.pdf
Acrord32.exe C:\Users\BW5.pdf
Acrord32.exe C:\Users\BW6.pdf
EXIT

The above batch file opens the first PDF only, then waits until I close it for the next PDF file to open. How can I have all the PDF documents open at the same time? (Like going to Acrobat Reader, file->Open->xx.pdf)

上面的批处理文件只打开第一个 PDF,然后等到我关闭它以打开下一个 PDF 文件。如何同时打开所有 PDF 文档?(比如去Acrobat Reader,file->Open->xx.pdf)

回答by Assaf Lavie

Use start:

使用start

start acrord32.exe 1.pdf
start acrord32.exe 2.pdf
start acrord32.exe 3.pdf

Or even (as Johannes R?ssel suggests in the comment below):

甚至(正如 Johannes R?ssel 在下面的评论中所建议的那样):

start 1.pdf
start 2.pdf
start 3.pdf

Would probably work as well (depending on your default PDF viewer).

可能也能工作(取决于您的默认 PDF 查看器)。

Note that when using startyou have to be careful when using quoted arguments, as the following won't work (the first quoted argument is interpreted as the title for a new console window):

请注意,start使用带引号的参数时必须小心,因为以下将不起作用(第一个带引号的参数被解释为新控制台窗口的标题):

start "1.pdf"

Instead you'll have to do the following:

相反,您必须执行以下操作:

start "" "1.pdf"

It's an annoying quirk of start, but you have to effectively supply a dummy title in this case to properly open the specified file (even though the title is unnecessary as this won't create a new console window).

这是一个烦人的怪癖start,但在这种情况下,您必须有效地提供一个虚拟标题才能正确打开指定的文件(即使标题是不必要的,因为这不会创建新的控制台窗口)。

A list of other available batch commands.

其他可用批处理命令的列表。

回答by Kurt Pfeifle

For me it works even without the startcommand. I use:

对我来说,即使没有start命令它也能工作。我用:

c:\path\to\my.pdf

in cmd.exe windows frequently, and it always opens Acrobat Reader (my default viewer on Windows). In a batchfile I've written to generate PDF via Ghostscript, my last two lines are:

在 cmd.exe 窗口中经常出现,它总是打开 Acrobat Reader(我在 Windows 上的默认查看器)。在我编写的通过 Ghostscript 生成 PDF 的批处理文件中,我的最后两行是:

"%ouptutpath%\%outputfile%.pdf"
"%outputpath%\%outputfile%-optimized.pdf"

which automatically opens both generated PDFs in two different Reader windows. (My %outputpath%contains spaces, the %outputfile%may also have some...)

它会在两个不同的阅读器窗口中自动打开两个生成的 PDF。(我的%outputpath%包含空格,%outputfile%可能还有一些......)

回答by Feroz

Thanks for the above answers.

感谢以上的回答。

I also tried below, working fine:

我也在下面尝试过,工作正常:

start /B excel.exe "D:\my first file.xlsx" "E:\my second file.xlsx" "D:\working folder\my third file.xlsx"

start /B excel.exe "D:\我的第一个文件.xlsx" "E:\我的第二个文件.xlsx" "D:\工作文件夹\我的第三个文件.xlsx"

回答by JSON C11

For every pdf file in the specified directory, use the start command on that file:

对于指定目录中的每个 pdf 文件,对该文件使用 start 命令:

for %f ("C:\Users\*.pdf") do start %f

As per the Microsoft Docs:

根据 Microsoft Docs:

For runs a specified command for each file in a set of files.

for {%variable|%%variable} in (set) do command [ CommandLineOptions]

For 为一组文件中的每个文件运行指定的命令。

for {%variable|%%variable} in (set) do command [ CommandLineOptions]

回答by JSON C11

Have you tried whether Acrobat Reader allows for more files on the commandline, ie.

您是否尝试过 Acrobat Reader 是否允许在命令行上显示更多文件,即。

start acrord32.exe 1.pdf 2.pdf 3.pdf

回答by JSON C11

Thank you!

谢谢!

Using start did the trick. I had to use start as many times as the number of pdf documents I want to open. For some reason

使用 start 成功了。我必须使用 start 的次数与我要打开的 pdf 文档的数量一样多。因为某些原因

start acrord32.exe 1.pdf 2.pdf 3.pdf

启动 acrord32.exe 1.pdf 2.pdf 3.pdf

opens only the first document. So I guess Acrobat reader might not allow for more files on the command line.

只打开第一个文档。所以我猜 Acrobat reader 可能不允许在命令行上有更多文件。

I rally appreciate your answers.

我非常感谢您的回答。