如何批量合并PDF文档

发布于 2024-11-30 01:51:05 字数 489 浏览 1 评论 0原文

我正在寻找一个批处理文件或一个 vbscript,它将像 pdf 文件名一样合并。应该合并的文件将具有相同的文件名,直到第一个“.”。我的整个文件夹包含大约 4000 个文件。文件扩展名符合以下格式

1111111111111111.22222222.pdf ==> 1是0-9的任意16个数字,2是0-9的任意8个数字

我想以批处理方式合并文件夹中的类似文件。直到第一个文件名相同的所有文件都应合并为“.”。

示例: 1111111111111111.25484686.pdf 应与 1111111111111111.54874568 合并,而 5555555555555555.78468767 应与 5555555555555555.48687654 合并5555555555555555.68974582

文件可以输出到另一个文件夹,但这不是必需的。输出后的新文件名也没关系,只要能用就行。

我知道有软件可以处理这个问题,但是拖放所有类似的文件来合并它们会花费很长时间。

I am looking for either a batch file or a vbscript that will merge like pdf file names. The files that should be combine will have the same file name all the way to the first "." I have entire folders that contain about 4000 files. The file extensions match the following format

1111111111111111.22222222.pdf ==> 1 is any 16 numbers 0-9 and 2 is any 8 numbers 0-9

I would like to merge the like files of the folder in batch style. All the files that have identical file name up to the first should be merged "."

Example: 1111111111111111.25484686.pdf should merge with 1111111111111111.54874568 while 5555555555555555.78468767 should merge with 5555555555555555.48687654 and 5555555555555555.68974582

The files could be outputted to another folder but is not required. The new file name after it is outputted doesnt matter either as long as it works.

I know that there is software that is out there that will handle this but it would take too long to drag and drop all like files to merge them.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

你的他你的她 2024-12-07 01:51:05

Google 搜索发现 http://www.pdfsam.org/ - 一个提供免费 PDF 合并实用程序的网站具有命令行界面(以及 GUI)。我不知道这有多好用。确保您获得的是该网站提供的免费实用程序,而不是同一网站上宣传的竞争对手的解决方案。

还有许多其他实用程序,其中大多数都是收费的。

一旦您弄清楚如何使用所选实用程序的命令行界面,您就可以使用如下所示的批处理文件来动态构建要合并的文件列表。 (此批处理代码未经测试。这个概念肯定会起作用,但可能需要一些调试)

@echo off
setlocal enableDelayedExpansion

:: This initial loop determines which files need to be merged
:: and then calls :merge for each unique set of files. This top
:: loop should work no matter what utility you choose.
set "current="
set cnt=0
:: for current directory, LOC should be empty (or .\)
:: for any other path, LOC should include \ at end
set "LOC="
for %%F in ("%LOC%*.*.pdf") do (
  for /f "tokens=1,* delims=." %%A in ("%%~nF") do (
    if "%%A" neq "!current!" (
      if defined current call :merge
      set cnt=0
      set current=%%A
    )
    set /a cnt+=1
    set pdf.!cnt!=%%~fF
  )
exit /b


:merge
:: This routine should build the command line to merge the current
:: file list contained in pdf.1 through pdf.!cnt!
::
:: Below is code to build a hypothetical file list to be used on
:: the merge command line. This will obviously need to be modified
:: based on the syntax of your chosen merge utility.
::
  set "list="
  for /l %%N in (1 1 !cnt!) do set list=!list! -f "!pdf.%%N!"
::
::
:: The rest is up to you!
::
exit /b

A Google search found http://www.pdfsam.org/ - a site that offers a free PDF merge utility that has a command line interface (as well as a GUI). I have no idea how well this works. Make sure you get the free utility offered by this site and not the competitor's solution that is advertised on the same site.

There are many other utilities out there, most of them for a fee.

Once you figure out how to use the command line interface of your utility of choice, you can use a batch file like the one below to dynamically build your list of files to merge. (This batch code is untested. The concept will definitely work, but it may need some debugging)

@echo off
setlocal enableDelayedExpansion

:: This initial loop determines which files need to be merged
:: and then calls :merge for each unique set of files. This top
:: loop should work no matter what utility you choose.
set "current="
set cnt=0
:: for current directory, LOC should be empty (or .\)
:: for any other path, LOC should include \ at end
set "LOC="
for %%F in ("%LOC%*.*.pdf") do (
  for /f "tokens=1,* delims=." %%A in ("%%~nF") do (
    if "%%A" neq "!current!" (
      if defined current call :merge
      set cnt=0
      set current=%%A
    )
    set /a cnt+=1
    set pdf.!cnt!=%%~fF
  )
exit /b


:merge
:: This routine should build the command line to merge the current
:: file list contained in pdf.1 through pdf.!cnt!
::
:: Below is code to build a hypothetical file list to be used on
:: the merge command line. This will obviously need to be modified
:: based on the syntax of your chosen merge utility.
::
  set "list="
  for /l %%N in (1 1 !cnt!) do set list=!list! -f "!pdf.%%N!"
::
::
:: The rest is up to you!
::
exit /b
治碍 2024-12-07 01:51:05

这个软件,Dysprosium,可以批量合并,无需编写批处理文件,也无需拖动并且可以免费获取和使用。正如预期的那样,将所有批次放在同一个文件夹中就足够了。但是您需要拥有与批处理中的文件大小成比例的硬件资源。

它是一个简单的轻型“JAR”文件,可移植,无需安装在操作系统上。

由于它是基于 Java 的软件,因此您还需要增加可用于 Java 运行时的 Java 内存。 Java 需要占用一部分物理内存来渲染大型 PDF 文件。此 wiki 解释了如何增加 Java 运行时内存。

(恕我直言)使用现成的软件,您无法合并总大小大于 3GB-3.5GB 的 PDF 批次。

This software, Dysprosium, can batch-merge without writing a batch file being necessary and without drag and drop and it is free to get and use. It is enough to put all the batch in the same folder, as expected. But you need to have hardware resources proportional to the size of files in your batch.

It is a simple light "JAR" file portable without being installed on operating system.

As it is a Java based software, you also need to increase the Java memory available for Java run time. Java needs to grab a portion of physical memory to render large PDF files. This wiki explains how you can increase Java Run Time Memory.

(IMHO) With off the shelf software you can't merge PDF batches which are in total size greater than 3GB-3.5GB.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文