#!/usr/bin/env python
import os, random
# This script deletes all shares that exceed the specified maximum.
MAX=3
STORAGE_PATH="/home/user/.tahoe/storage/shares"
from os.path import join, getsize
for root, dirs, files in os.walk(STORAGE_PATH):
count = len(files)
if count > MAX:
print root, count
random.shuffle(files)
for file in files[MAX:]:
path = os.path.join(root, file)
print "to delete ", path
# uncomment the line below to actually delete
#os.remove(path)