CopyFiles

Copies the content of files from one path on to another path.
For each output document, several metadata values are set with information about the file. By default, files are copied from the input folder (or a subfolder) to the same relative location in the output folder, but this doesn't have to be the case. The output of this module are documents with metadata representing the files copied by the module. Note that the input documents are not output by this module.

Usage

  • CopyFiles(DocumentConfig patterns)

    Copies all files that match the specified globbing patterns and/or absolute paths. This allows you to specify different patterns and/or paths depending on the input document. When this constructor is used, the module is evaluated once for every input document, which may result in copying the same file more than once (and may also result in IO conflicts since copying is typically done in parallel). It is recommended you only specify a function-based source path if there will be no overlap between the path returned from each input document.

    • patterns

      A delegate that returns one or more globbing patterns and/or absolute paths.

  • CopyFiles(params string[] patterns)

    Copies all files that match the specified globbing patterns and/or absolute paths. When this constructor is used, the module is evaluated only once against empty input document. This makes it possible to string multiple CopyFiles modules together in one pipeline. Keep in mind that the result of the whole pipeline in this case will be documents representing the files copied only by the last CopyFiles module in the pipeline (since the output documents of the previous CopyFiles modules will have been consumed by the last one).

    • patterns

      The globbing patterns and/or absolute paths to read.

Fluent Methods

Chain these methods together after the constructor to modify behavior.

  • To(Func<, , > destinationPath)

    Specifies an alternate destination path for each file (by default files are copied to their same relative path in the output directory). The output of the function should be the full file path (including file name) of the destination file. If the delegate returns null for a particular file, that file will not be copied. This overload allows you to view the Wyam.Common.IO.IFile where the module would normally have copied the file to and then manipulate it (or not) as appropriate.

    • destinationPath

      A delegate that specifies an alternate destination. The first parameter contains the source Wyam.Common.IO.IFile and the second contains an Wyam.Common.IO.IFile representing the calculated destination.

  • To(Func<, > destinationPath)

    Specifies an alternate destination path for each file (by default files are copied to their same relative path in the output directory). The output of the function should be the full file path (including file name) of the destination file. If the delegate returns null for a particular file, that file will not be copied.

    • destinationPath

      A delegate that specifies an alternate destination. The parameter contains the source Wyam.Common.IO.IFile.

  • Where(Func<, > predicate)

    Specifies a predicate that must be satisfied for the file to be copied.

    • predicate

      A predicate that returns true if the file should be copied.

Output Metadata

The metadata values listed below apply to individual documents and are created and set by the module as indicated in their descriptions.

  • Keys.DestinationFilePath: Wyam.Common.IO.FilePath

    The full path (including file name) of the destination file.

  • Keys.SourceFilePath: Wyam.Common.IO.FilePath

    The full path (including file name) of the source file.

GitHub