Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
171 views
in Technique[技术] by (71.8m points)

windows - how to remove directories structures not accessed since a specific date?

how to remove directories structures not accessed since a specific date ?

it might look like something :

Get-ChildItem -Path $path -Recurse -Force -filter IDENTIFY_DIRECTRORY | Where-Object { !$_.PSIsContainer -and $_.CreationTime -lt $limit } | IDENTIFYTHELASTACCCESSTIME | Remove-Item -Force

IDENTIFY_DIRECTORY : I guess it is : -Directory parameter to Get-ChildItem command (select directories only not files)

IDENTIFYTHELASTACCCESSTIME : here I mean check if directory or sub-path/file has been accessed/read since a date I would set from a variable

Final goal of that is to purge useless files from a fileserver to free a maximum of space. I already did :

Get-ChildItem -Path $path -Recurse -Force -filter *.log | Where-Object { !$_.PSIsContainer -and $_.CreationTime -lt $limit } | Remove-Item -Force

maybe workaround

Get-ChildItem -Path "F:" $_.LastAcessTime -Recurse -Directory -Force -<somemorecommandlineparameters> ......
question from:https://stackoverflow.com/questions/65842972/how-to-remove-directories-structures-not-accessed-since-a-specific-date

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...