Delete files from folder older than any days from PowerShell script

PowerShell script
# Defines how many days the files can stay in the defined directory
$limit = (Get-Date).AddDays(-7)
# Defines the destination directory to clean files
$path = "Put your folder path here"

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Guilherme Matheus

Guilherme Matheus

Mechanical Engineer Business Intelligence developer, passionate about technology, I have knowledge and experience to create a BI architecture and much more 📚.