Skip to main content
This is a pre-production deployment of Warehouse. Changes made here affect the production instance of PyPI (pypi.python.org).
Help us improve Python packaging - Donate today!

Purge old files using constraints

Project Description

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] [--dry-run] [--include PATTERN]
                       [--exclude PATTERN]
                       MIN_AGE DIRECTORY

positional arguments:
  MIN_AGE               Minimum age of files
  DIRECTORY             Directory to be scanned

optional arguments:
  -h, --help            show this help message and exit
  --debug, -D           Show debug messages
  --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. :)

Release History

Release History

This version
History Node

1.0.0

Download Files

Download Files

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

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
purge-old-files-1.0.0.tar.gz (4.3 kB) Copy SHA256 Checksum SHA256 Source Oct 15, 2017

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting