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

Powershell command to delete subfolders of a type: DAY-MONTH-YEAR

$
0
0

Greetings!

I have a script which makes backups using Windows server backup. A script creates a folder DD-MM-YYYY and put the backup into this folder, soo every next day it creates a different folder with DD-MM-YYYY name.

Now I am searching an idea (a powershell command) which would leave only the last three backups.

For example If I have folders:

06-09-2013
13-09-2013
20-09-2013
27-09-2013
04-10-2013
...

Is there a way to make a script which would leave only the last three folders (for example: it would leave 04-10-2013,27-09-2013,20-09-2013, but delete the other subfolders and their contents/subfolders)?


bostjanc


Viewing all articles
Browse latest Browse all 21975

Trending Articles



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