An open API service indexing awesome lists of open source software.

https://github.com/ran-dall/export-contents


https://github.com/ran-dall/export-contents

Last synced: 10 months ago
JSON representation

Awesome Lists containing this project

README

          

# Export-Contents

## Overview
Export-Contents is a PowerShell module designed to efficiently gather and concatenate file contents from a directory into a single output file. It provides flexible filtering options, path handling, and hidden file support, making it ideal for code analysis, documentation, and content aggregation tasks.

## Installation
```powershell
Install-Module -Name Export-Contents -Scope CurrentUser -Force
```

## Features

### Directory Content Export
```powershell
# Basic usage with defaults
Export-DirectoryContents -Path "C:\Projects\MyCode"

# Include hidden files with absolute paths
Export-DirectoryContents -Path "C:\Projects\MyCode" `
-OutputFile "FullExport.txt" `
-UseAbsolutePaths `
-IncludeHiddenFiles
```

Creates a consolidated export with:
- File headers marking content boundaries
- Relative or absolute path references
- Optional hidden file inclusion
- Customizable output location
- System file filtering

### Directory Structure
```
Export-Contents/
├── Source/
│ ├── Public/ # Exported functions
│ │ └── Export-DirectoryContents.ps1
│ ├── Private/ # Internal functions
│ │ └── Get-FilteredFile.ps1
├── Tests/ # Pester tests
├── Export-Contents.psm1 # Module loader
├── Export-Contents.psd1 # Module manifest
└── README.md
```

### Usage Examples

#### Basic Export
```powershell
# Export current directory contents
Export-DirectoryContents

# Export specific directory with custom output file
Export-DirectoryContents -Path "C:\Source\MyProject" -OutputFile "ProjectContents.txt"
```

#### Advanced Options
```powershell
# Include hidden files with absolute paths
Export-DirectoryContents -Path "C:\Logs" `
-OutputFile "FullLogs.txt" `
-UseAbsolutePaths `
-IncludeHiddenFiles

# Export with relative paths (default)
Export-DirectoryContents -Path ".\src" -OutputFile "SourceCode.txt"
```

### Output Format
The exported file contains entries in this format:
```
--- FILE: ./path/to/file.txt ---
[File contents here]

--- FILE: ./path/to/another.txt ---
[File contents here]
```

## Requirements
- PowerShell 5.1 or later
- Windows PowerShell or PowerShell Core

## Parameters

### Export-DirectoryContents
- **`-Path`** (String)
- Directory to process
- Default: Current directory (".")
- Accepts pipeline input

- **`-OutputFile`** (String)
- Output file path
- Default: "DirectoryContents.txt"
- Creates or overwrites existing file

- **`-UseAbsolutePaths`** (Switch)
- Use full file paths in output
- Default: False (uses relative paths)

- **`-IncludeHiddenFiles`** (Switch)
- Include hidden files in export
- Default: False (excludes hidden files)

## Contributing
Contributions are welcome! Please feel free to submit a Pull Request.

## License
This module is licensed under the OSL-3.0 License.