需要在目录中组合大量文件

tnr*_*ish 41 concatenation notepad++

我在一个目录中有50到60个文件,我需要定期连接到一个文件中.

我想过使用notepad ++认为可能有一个插件可以帮助但却找不到它.

还有其他想法吗?

JYe*_*ton 83

假设这些是文本文件(因为你使用的是notepad ++)并且你在Windows上,你可以设计一个简单的批处理脚本来将它们连接在一起.

例如,在包含所有文本文件的目录中,执行以下命令:

for %f in (*.txt) do type "%f" >> combined.txt
Run Code Online (Sandbox Code Playgroud)

这会将匹配*.txt的所有文件合并到一个名为combined.txt的文件中.

欲获得更多信息:

http://www.howtogeek.com/howto/keyboard-ninja/keyboard-ninja-concatenate-multiple-text-files-in-windows/

  • @Mowgli如果您从批处理文件中运行它,则需要将%符号加倍.请参见http://stackoverflow.com/a/7769757/161052 (7认同)

dwe*_*ner 64

使用Windows"复制"命令.

C:\Users\dan>help copy
    Copies one or more files to another location.

    COPY [/D] [/V] [/N] [/Y | /-Y] [/Z] [/L] [/A | /B ] source [/A | /B]
         [+ source [/A | /B] [+ ...]] [destination [/A | /B]]

      source       Specifies the file or files to be copied.
      /A           Indicates an ASCII text file.
      /B           Indicates a binary file.
      /D           Allow the destination file to be created decrypted
      destination  Specifies the directory and/or filename for the new file(s).
      /V           Verifies that new files are written correctly.
      /N           Uses short filename, if available, when copying a file with 
                   a non-8dot3 name.
      /Y           Suppresses prompting to confirm you want to overwrite an
                   existing destination file.
      /-Y          Causes prompting to confirm you want to overwrite an
                   existing destination file.
      /Z           Copies networked files in restartable mode.
      /L           If the source is a symbolic link, copy the link to the 
                   target
                   instead of the actual file the source link points to.

    The switch /Y may be preset in the COPYCMD environment variable.
    This may be overridden with /-Y on the command line.  Default is
    to prompt on overwrites unless COPY command is being executed from
    within a batch script.

    **To append files, specify a single file for destination, but 
    multiple files for source (using wildcards or file1+file2+file3 
    format).**
Run Code Online (Sandbox Code Playgroud)

所以在你的情况下:

copy *.txt destination.txt

将所有.txt文件按字母顺序连接到destination.txt

谢谢你的询问,我学到了新东西!

  • 你也可以根据帮助描述指定顺序:copy file1.txt + file2.txt + file3.txt destination.txt (3认同)
  • 毕竟不需要PowerShell脚本.也学到了新的东西.谢谢. (2认同)

小智 12

copy *.txt all.txt
Run Code Online (Sandbox Code Playgroud)

这会将文件夹的所有文本文件连接到一个文本文件all.txt

如果您有任何其他类型的文件,如sql文件

copy *.sql all.sql
Run Code Online (Sandbox Code Playgroud)

  • 这将屠宰例如utf8编码为许多字符的不可接受的ANSI替代品. (3认同)

Md.*_*lom 6

是的,一个名为"combine"的插件可用于记事本++.链接:.>> 组合插件用于Notepad ++

您可以通过插件管理器安装它.这个插件的额外好处是:"你可以在合并时保持文件的顺序,它是根据打开的文件的顺序打开(见标签)".