dirsync is an advanced Python library and command-line tool for synchronizing directory trees. It is based on Anand B Pillai's Python robocopier and provides functionalities like reporting differences, syncing content, and updating existing content with various options for filtering and behavior. The current version is 2.2.6, and it appears to have a stable, though infrequent, release cadence.
pip install dirsyncVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to use the `sync` function to synchronize files from a source directory to a target directory. It includes creating dummy directories and files, performing a 'sync' operation with verbose output and target directory creation, and finally cleaning up.
Always provide the `action` argument, e.g., `sync(sourcedir, targetdir, 'sync', ...)`.
Ensure the target directory exists before calling `sync`, or pass `create=True` (Python) / `--create` (CLI).
Construct regex patterns to match the full path (e.g., `^.*\.txt$` for all .txt files). For the Python API, pass patterns as a list: `include=['^.*\.txt$']`.
If using the Python API, all options must be passed programmatically as arguments to the `sync` function. For CLI, ensure options are defined in the config file or as command-line arguments (which override config).
Specify the synchronization action as the third positional argument: `from dirsync import sync; sync('source_dir', 'target_dir', 'sync')`.Either create the target directory manually before calling `sync`, or pass the `create=True` argument: `sync('source_dir', 'target_dir', 'sync', create=True)`.Ensure regex patterns are anchored (`^` and `$`) to match the full path (e.g., `r'^.*\.py$'`). When using the Python API, provide patterns as a list: `sync(..., include=['^.*\.py$'])`.
No dependency data recorded yet.