Python, Deleting all files in a folder older than X days

前端 未结 10 624
无人及你
无人及你 2020-12-08 00:39

I\'m trying to write a python script to delete all files in a folder older than X days. This is what I have so far:

import os, time, sys

path = r\"c:\\user         


        
10条回答
  •  暖寄归人
    2020-12-08 00:42

    There's script which delete files only if you running out of space, this is good fit for logs and backups in production environment.

    Delete old files will eventually remove all your backups if new backups are not being added

    https://gist.github.com/PavelNiedoba/811a193e8a71286f72460510e1d2d9e9

提交回复
热议问题