I am using PsInfo from sysinternals to return drive information in the form of a csv.
When I run this command.
psinfo -c -d volume
I get the following output.
PCName,,C:,Fixed,NTFS,,930.97 GB,705.81 GB,75.8%,D:,CD-ROM,,,,,0.0%,G:,Fixed,NTFS,My Book,1862.98 GB,889.71 GB,47.8%
My goal here is to parse that output to achieve this format:
PCNAME,,
,,C:,Fixed,NTFS,,930.97 GB,705.81 GB,75.8%
,,G:,Fixed,NTFS,My Book,1862.98 GB,889.71 GB,47.8%
So when the output is read by a spreadsheet viewer it appears readable and organized.
I've tried using regex to match the drive letter bit I don't know how to correctly capture the output.
Edit: (forgot to actually post my code...) This is what I have so far.
ECHO OFF
For /f "tokens=1*" %%x in ('net view ^| find "\\"') do (psinfo %%x filter -d -c >> out.csv & echo. >> out.csv)
::used to remove blanmk lines from output
@jrepl "^[ \t]*(.*?)[ \t]*$" "$1?$1:false" /jmatch /f out.csv /o -
pause