Должен объединить много файлов в каталоге

У меня есть 50 - 60 файлов в каталоге, который я должен связать в единственный файл регулярно.

Я думал об использовании блокнота ++ думающий, что был, вероятно, плагин, который поможет, но не смог найти тот.

Какие-либо другие мысли?

41
задан tnriverfish 5 August 2010 в 19:43
поделиться

3 ответа

Предполагая, что это текстовые файлы (поскольку вы используете notepad ++) и что вы работаете в Windows, вы можете создать простой пакетный сценарий для их объединения.

Например, в каталоге со всеми текстовыми файлами выполните следующие действия:

for %f in (*.txt) do type "%f" >> combined.txt

Это объединит все файлы, соответствующие * .txt, в один файл с именем комбинированный.txt.

Для получения дополнительной информации:

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

83
ответ дан 27 November 2019 в 00:06
поделиться

вы можете использовать сценарий PowerShell следующим образом

$sb = new-object System.Text.StringBuilder

foreach ($file in Get-ChildItem -path 'C:\temp\xx\') {
    $content = Get-Content -Path $file.fullname
    $sb.Append($content)
}
Out-File -FilePath 'C:\temp\xx\c.txt' -InputObject $sb.toString()
1
ответ дан 27 November 2019 в 00:06
поделиться

Используйте команду 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).**

Итак, в вашем случае:

copy *.txt destination.txt

Объединит все файлы .txt в алфавитном порядке в destination.txt

Спасибо за вопрос, я узнал кое-что новое!

64
ответ дан 27 November 2019 в 00:06
поделиться
Другие вопросы по тегам:

Похожие вопросы: