deleterecursiveDirectories whereempty andnamenot in ('src', 'res')
Move pdf files older than 9 days to the recycle bin.
Python
import os, time from send2trash import send2trash
path = "c:\\somepath"
now = time.time()
for filename in os.listdir(path):
p = os.path.join(path, filename) if os.path.isfile(p): if filename.endswith(".pdf"):
filestamp = os.stat(p).st_mtime
filecompare = now - 9 * 86400 if filestamp < filecompare:
send2trash(p)
Perun2
delete'*.pdf' wherelifetime > 9 days
Of all directories here, hide these that do not contain any mp3 file.
C#
foreach(var d in Directory.GetDirectories("c://some//path"))
{ if (!Directory.EnumerateFiles(d, "*.mp3") .Any())
{
DirectoryInfo di = Directory.CreateDirectory(d);
di.Attributes = FileAttributes.Directory | FileAttributes.Hidden;
}
}