简体   繁体   English

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

[英]Opening multiple PDF documents using batch file

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. 上面的批处理文件仅打开第一个PDF,然后等待直到我关闭它才能打开下一个PDF文件。 How can I have all the PDF documents open at the same time? 如何同时打开所有PDF文档? (Like going to Acrobat Reader, file->Open->xx.pdf) (就像转到Acrobat Reader一样,文件-> Open-> xx.pdf)

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): 甚至(如JohannesRö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 start you 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. 其他可用批处理命令的列表。

For me it works even without the start command. 对我来说,即使没有start命令,它也可以工作。 I use: 我用:

c:\path\to\my.pdf

in cmd.exe windows frequently, and it always opens Acrobat Reader (my default viewer on Windows). 在cmd.exe Windows中经常出现,并且它总是打开Acrobat Reader(Windows上的默认查看器)。 In a batchfile I've written to generate PDF via Ghostscript, my last two lines are: 在我编写的通过Ghostscript生成PDF的批处理文件中,最后两行是:

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

which automatically opens both generated PDFs in two different Reader windows. 会自动在两个不同的Reader窗口中打开两个生成的PDF。 (My %outputpath% contains spaces, the %outputfile% may also have some...) (我的%outputpath%包含空格, %outputfile%也可能有一些...)

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" 开始/ B excel.exe“ D:\\我的第一个文件.xlsx”“ E:\\我的第二个文件.xlsx”“ D:\\工作文件夹\\我的第三个文件.xlsx”

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

For runs a specified command for each file in a set of files. 对于为一组文件中的每个文件运行一个指定的命令。

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

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

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

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. 我不得不使用start作为我要打开的pdf文档的次数。 For some reason 由于某些原因

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. 我非常感谢您的回答。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM