I am trying to parse filenames (strings) and convert them to dates in powershell using the following line:
([datetime]::ParseExact($DirName.BaseName,'yyyyMMdd',$null)
The problem is, not all of the folders in that directory following that naming convention. How would I first test to see if the folder fits the naming convention and if it does, convert it to a date time object? Any help would be greatly appreciated.