Power Shell script to purge a directory by saving last # sub folders (According to regex pattern)

I had to create a mechanism to purge a directory that is built out of builds in format of version e.g. 11.0.21.21.

The requirement was to save last X builds and other should be purged, so i created the following PS script for it

The code iterate on the input folder and extracting all the folders in the pattern of the version, sort it by flattening the version to full string (static size) and than skipping the first X

GetFolderToPurge

I still find my self struggling with powershell (its not as easy as i though it would be)

Power Shell script to purge a directory by saving last # sub folders (According to regex pattern) Power Shell script to purge a directory by saving last # sub folders (According to regex pattern) Reviewed by Ran Davidovitz on 3:36 PM Rating: 5

No comments:

Powered by Blogger.