#Brett Paufler #(c) Copyright 2020-04-05 #PowerShell Script saved as .txt #So, needs to be renamed/resaved prior to use #Converts a List of Custom File Names to csv #files names of form # yyyy-MM-dd HH.mm.ss-POINTS #to .csv of form # yyyy-MM-dd HH.mm.ss,POINTS #Custom One Shot #So, really, I have no idea why another would want to use #The first and last data points in the resultant .csv are fictitious #List of Files, Names of Which Contain The Data $DIR_IN = 'C:\alpha\input' $Items = Get-ChildItem -Path $DIR_IN #Arbitrary Start Time, Matching The First File In #This Will Be Obfuscated $start_string = '0000-00-00 00.00.00' $zero_hour = [datetime]::ParseExact($start_string,'yyyy-MM-dd HH.mm.ss',$null) $zero_hour #Text String Out #Must Have Double Quotes for `n newline to work $output = "DAY,POINTS`n" #Main Loop, Parsing the File Names To Extract Data ForEach ($raw_data in $items) { #File Name IN: No Directory, No Extenstion $raw_data.BaseName #String Representation of Points $points = $raw_data.BaseName.Substring(20) $points #String Representation of Date $date_string = $raw_data.BaseName.Substring(0,19) $date_string #PowerShell Time Object $date = [datetime]::ParseExact($date_string,'yyyy-MM-dd HH.mm.ss',$null) $elapsed_time = New-TimeSpan -Start $zero_hour -End $date #Hours to Quite a Few Digits $elapsed_time.TotalDays $output += $elapsed_time.TotalDays.ToString() + ',' $output += $points + "`n" } #All These Empty Variables Simply Echo To Screen #It's a Print Statement $output #File Out Containing Desired CSV $FILE_OUT = 'C:\alpha\output\imgur_raw_data.csv' $output > $FILE_OUT