In a folder structure I have .stb files where name is unknown, and subfolders matching the name of the .stb file.
A folder can look like this:
C:\path\file1.stb
C:\path\file1\...
C:\path\file2.stb
C:\path\file2\..
The .stb file is tab delimited and look something like this:
Call ID Latitude Longitude Date and Time Noe
wasd 12.1241234 12.1243 2021-12-15 07:45:13.123 Noe
wasd 12.1241234 12.1243 2021-12-15 07:45:13.123 Noe
wasd 12.1241234 12.1243 2022-01-15 07:45:13.123 Noe
If a .stb contain a line where date is older than "$limit" the file and matching subfolder (and its content) should be deleted.
What I tested is:
$limit = (Get-Date).AddDays(-41).Date
$test = (Import-Csv -Path (Get-ChildItem -Path C:\Users\steff\Documents\ -Filter '*.stb').FullName -Delimiter "`t" | Where-Object { ([datetime]$_.'Date and Time') -lt $limit } )
But this only gives the output of file, and im not sure how to proceed to know what the actual filename is, in order to delte the .stb file and the matching subfolder. I am limited to Powershell here. Anyone know how to proceed?