Skip to main content

Purge old files

Simple tool to delete old files using a set of contraints.

If --include if used, only files matching the provided glob pattern are considered. This option can be used multiple times. By default, all files are considered.

Usage

$ purge-old-files -h
usage: purge-old-files [-h] [--debug | --quiet] [--syslog] [--dry-run]
                       [--include PATTERN] [--exclude PATTERN]
                       MIN_AGE [DIRECTORY [DIRECTORY ...]]

positional arguments:
  MIN_AGE               Minimum age of files
  DIRECTORY             Directory or glob pattern to be scanned (multiple
                        directories can be provided)

optional arguments:
  -h, --help            show this help message and exit
  --debug, -D           Show debug messages
  --quiet, -q           Only show warning messages
  --syslog, -s          Send log messages to /dev/log instead of stdout
  --dry-run, -d         Show which files should be deleted
  --include PATTERN, -i PATTERN
                        Include only files matching pattern
  --exclude PATTERN, -e PATTERN
                        Exclude files matching pattern

# Purge *.log files in /logs when they are older than 3 days
$ purge-old-files --include '*.log' 3d /logs

# Delete files from /backup when they are older than 1 week
$ purge-old-files 1w /backup

# Show which files from /backup are older than 3 months
$ purge-old-files --dry-run 3M /backup

File minimum age

Supported units:

  • s: seconds

  • m: minutes

  • h: hours

  • d: days

  • w: weeks

  • M: months (30 days)

  • y: years (365 days)

Installation

$ pip install purge-old-files

Requirements

  • Python 3.x

FAQ

  • Do you know you can do this with a simple shell script using find?

    Yep. I wrote those for years. They are also painful to maintain. And error prone. Feel free to use a shell script. :)

Metadata

Release files for purge-old-files 1.3.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for purge-old-files 1.3.0
File Size Uploaded Provenance Actions
purge-old-files-1.3.0.tar.gz 4.8 kB Without provenance Details for purge-old-files-1.3.0.tar.gz

Release files / purge-old-files-1.3.0.tar.gz

Download URL purge-old-files-1.3.0.tar.gz
Size 4.8 kB
Tags Source
SHA-256 checksum
How to use checksums
62aea42fde4f810f496c3dced29724c3f28596ed5cc0f7fcaefd05324ec9e9d4
BLAKE2b-256 checksum
How to use checksums
abae4b94ffffec236d78f50b0d8dd48a788bca757db2bc9caa01f2564c5463ea
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.10.0 setuptools/41.0.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.5.1

Security for purge-old-files 1.3.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.3.0 This release

1 release file No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page