Quantcast
Channel: Windows PowerShell forum
Viewing all articles
Browse latest Browse all 21975

Get List of Files Where Total Size is Greater Than Value

$
0
0

I am trying to keep a folder's total size below a specified size limit.  If it is greater than a certain size then delete the oldest files until the folder is below the limit once again.

As of now, my script gets the oldest files, 1000 at a time, and deletes them and then checks to see if the directory is below the limit.  If not, it will get the next oldest 1000 and check again.

Earlier in the script, I calculate how much space needs to be freed up in order to get the directory size below the limit.  Is it possible to get the oldest files where their total size will get the directory below the limit after deleting them instead of deleting 1000 at a time and then checking the size of the directory.


Viewing all articles
Browse latest Browse all 21975

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>