I have some zip files that all ends with:
Some nameA 1.0.0 rev. 110706.zip
Some nameB 1.0.0 rev. 110806.zip
Some name moreC 1.0 rev. 120904.zip
name 1.1 rev. 130804.zip
In PowerShell I would like to read those file names, create a new text file that contains only the versions but converted into the following format:
1.0.0.110706
1.0.0.110806
1.0.120904
1.1.130804
For now I do:
$files = Get-ChildItem "." -Filter *.zip
for ($i=0; $i -lt $files.Count; $i++) {
$FileName = $files[$i].Name
$strReplace = [regex]::replace($FileName, " rev. ", ".")
$start = $strReplace.LastIndexOf(" ")
$end = $strReplace.LastIndexOf(".")
$length = $end-$start
$temp = $strReplace.Substring($start+1,$length-1)
$temp
}
I have looked at: Use Powershell to replace subsection of regex result
To see if I can get a more compact version of this. Any suggestions given the above pattern?