Skip to main content

A simple script for file archiving.

Project description

h3a

A simple script for file archiving.

  • Python: >=3.12
  • Test Coverage: 100%
  • Well Typed: Yes
  • License: ISC

Usage

$ h3a --help
Usage: h3a [OPTIONS]

  A simple script for file archiving.

Options:
  -c, --config FILE            Path to config file.  [default: h3a.yaml]
  -e, --encoding TEXT          Encoding of the config file.  [default: utf-8]
  --help-config                Show config schema and exit.
  -y, --skip-confirm           Skip confirmation prompt.
  -t, --threads INTEGER RANGE  Number of threads to use.  [x>=1]
  --dry-run                    Print plan and exit.
  --verbose                    Enable info-level logging.
  --debug                      Enable debug-level logging.
  --version                    Show the version and exit.
  --help                       Show this message and exit.

Example

Say you wanna archive all the Office files in the current directory except the ones starts with _:

some_directory/
+-- foo.docx
+-- bar.pptx
+-- baz.xlsx
`-- _blah.docx

You can first create a config file h3a.yaml:

# h3a.yaml
include:
  - '**/*.docx'
  - '**/*.pptx'
  - '**/*.xlsx'
exclude:
  - '_*.*'
on_conflict: overwrite

Then, execute h3a in the directory and confirm the archive plan:

h3a

Now you get your files archived: (The actual time tag differs.)

some_directory/
+-- h3a.yaml
+-- foo.docx
+-- foo_v20251024-123456.docx
+-- bar.pptx
+-- bar_v20251024-123456.pptx
+-- baz.xlsx
+-- baz_v20251024-123456.xlsx
`-- _blah.docx

Configuration Schema

$ h3a --help-config
include (list[str]):
    An array of glob patterns to include.
exclude (list[str], optional):
    An array of glob patterns to exclude. (default: [])
out_dir (str, optional):
    The output path prefix.
tag_time_source (typing.Literal['now', 'mtime', 'ctime'], optional):
    The source of the timestamp in the dest tag. (default: 'mtime')
tag_format (str, optional):
    The strftime format of the dest tag. (default: '_v%Y%m%d-%H%M%S')
tag_pattern (str, optional):
    A regex pattern to match existing dest tags. (default: '_v\\d{8}-\\d{6}')
on_conflict (typing.Literal['error', 'skip', 'overwrite'], optional):
    The action of existing dest files. (default: 'error')
threads (int, optional):
    The number of maximum threads to use. (default: 8)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

h3a-0.2.0.tar.gz (6.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

h3a-0.2.0-py3-none-any.whl (8.0 kB view details)

Uploaded Python 3

File details

Details for the file h3a-0.2.0.tar.gz.

File metadata

  • Download URL: h3a-0.2.0.tar.gz
  • Upload date:
  • Size: 6.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.6.11

File hashes

Hashes for h3a-0.2.0.tar.gz
Algorithm Hash digest
SHA256 185f3948990665b25249268ab475812d2446e7c05bbd6b7b343f40f0f908ea59
MD5 5eda51501a6c7fcdcce9de58cb002289
BLAKE2b-256 422d721fb472ba9dfa4c487d83a475f4f18c609747a4054f38640c927ddd127e

See more details on using hashes here.

File details

Details for the file h3a-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: h3a-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 8.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.6.11

File hashes

Hashes for h3a-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 97d07e872c13f8bf3ab69f7af9fa251cbfdb6ed5cdc641eac4fce4941a2ee926
MD5 1260eb85598f94b1b8534c51d8f7d947
BLAKE2b-256 f04102ba2c78c87500d11c377d93860979ae8f9b1eef042ff39c5fe93c3590b3

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page