I am trying to create a Purgejob in SQL Server server which deletes the .txt files which are older than 15 days.
Get-ChildItem –Path "D:\ABC\Project" -include *.txt –Recurse | Where-Object{$_.CreationTime –lt (Get-Date).AddDays(-15)} | Remove-Item
By running this query it is successfully deleting the .txt
files inside the project folder, but it is also deleting the subfolder .txt
files which are inside the project folder. I don't want to delete these files. All I want is to delete the .txt
files inside project folder but not in the subfolder of the project folder.