SyncFileContents is a .NET 9 console application that scans a directory for files with a specified name, compares their contents using SHA256 hashes, and allows the user to synchronize these files across the directory. It also provides Git integration for committing and pushing changes.
- Recursively scan a specified directory for files with a given name
- Support for multiple filenames (comma-separated) and wildcard patterns
- Compare file contents using SHA256 hashes
- Display file paths, creation times, and modification times grouped by hash
- Synchronize file contents across different directories within the scanned path
- Automatically skip files in nested Git repositories (submodules)
- Commit changes to Git repositories with automatic staging
- Fetch, merge, and push changes to remote repositories
- Interactive prompts with persistent history for paths and filenames
- Persistent Git credentials storage
To use SyncFileContents, you need to have .NET 9 SDK installed on your machine.
Clone the repository:
git clone https://github.com/ktsu-dev/SyncFileContents.gitNavigate to the project directory:
cd SyncFileContentsBuild the project:
dotnet buildRun the application with optional command-line arguments:
dotnet run -- [path] [filename]path: The path to recursively scan in. If not provided, you will be prompted to enter it interactively.filename: The filename to scan for. If not provided, you will be prompted to enter it interactively. Supports wildcards and comma-separated values.
To scan the current directory for files named example.txt and synchronize their contents:
dotnet run -- . example.txtTo scan a specific directory for multiple config files:
dotnet run -- /path/to/projects "config.json,settings.json"To run interactively without arguments:
dotnet run- Scan: The application recursively scans the specified directory for files matching the filename pattern
- Compare: Files are grouped by SHA256 hash to identify differing versions
- Display: Shows each unique hash with its associated file paths, creation times, and modification times
- Select: If only one file differs, it's automatically selected as the source; otherwise, you enter the hash to use as the sync source
- Preview: A dry-run shows which files will be updated
- Sync: After confirmation, files are copied from the source to all destinations
- Commit: Outstanding changes in Git repositories can be committed
- Push: Repositories with only SyncFileContents commits can be automatically pushed
On first run, you'll be prompted to enter your Git username and personal access token. These credentials are stored locally and used for push operations.
Clone the repository and navigate to the project directory:
git clone https://github.com/ktsu-dev/SyncFileContents.git
cd SyncFileContentsBuild the project:
dotnet buildTo run the tests, use the following command:
dotnet testThis project is licensed under the MIT License. See the LICENSE file for details.