我当前正在使用此快速批处理文件从各种计算机上获取所需的信息。我的问题是它创建了CSV文件,但它全都是一列。我计划使用python处理数据,但是如果全部都是一列,则很难做到这一点。
@echo off
(systeminfo | findstr /c:"Host Name"
systeminfo | findstr /c:"OS Name"
systeminfo | findstr /c:"System Model"
systeminfo | findstr /c:"System type"
systeminfo | findstr /c:"Total Physical Memory"
ipconfig | findstr IPv4
wmic diskdrive get size
wmic bios get serialnumber
wmic cpu get name)>>in.csv
答案 0 :(得分:1)
IP地址和磁盘驱动器上的所有输出,单行,逗号定界和子定界,因为其中有多个。子定界是分号。
MyBox,36527083,Packard Bell,3-2,Microsoft Windows 10,x64-based PC,17087881216,192.168.121.1;192.168.3.1;10.11.18.112,Intel(R) Core(TM) i7-4710HQ CPU @ 2.50GHz,2000396321280;63992678400;4000784417280;512105932800;1500299297280
@echo off
setlocal EnableDelayedExpansion
set "zManufacturer="
set "zHostName="
set "zOsName="
set "zSystemModel="
set "zSystemType="
set "zTotalPhysicalMemory="
set "zIpAddresses="
set "zHddSizes="
set "zCpuName="
set "zBiosSerial="
for /f "skip=1 tokens=1-6 delims=," %%A in ('wmic computersystem get Manufacturer^,Model^,TotalPhysicalMemory^,SystemType^,Workgroup /format:csv ^| findstr ","') do (
set "zHostName=%%A"
set "zManufacturer=%%B"
set "zSystemModel=%%C"
set "zSystemType=%%D"
set "zTotalPhysicalMemory=%%E"
)
for /f "tokens=2 delims=:" %%A in ('ipconfig ^| findstr /i ipv4') do set "zIpAddresses=!zIpAddresses!%%A"
set "zIpAddresses=!zIpAddresses:~1!"
set "zIpAddresses=!zIpAddresses: =;!"
for /f "tokens=1 delims=|" %%A in ('wmic os get name ^|findstr "|"') do set "zOsName=%%A"
for /f "tokens=2 delims=," %%A in ('wmic bios get serialnumber^,version /format:csv') do set "zBiosSerial=%%A"
for /f "tokens=2 delims=," %%A in ('wmic cpu get name^,version /format:csv') do set "zCpuName=%%A"
for /f "skip=1 tokens=2 delims=," %%A in ('wmic diskdrive get size^,TracksPerCylinder /format:csv ^|findstr /v /r "^$"') do set "zHddSizes=!zHddSizes!;%%A"
set "zHddSizes=!zHddSizes:~1!"
echo !zHostName!,!zBiosSerial!,!zManufacturer!,!zSystemModel!,!zOsName!,!zSystemType!,!zTotalPhysicalMemory!,!zIpAddresses!,!zCpuName!,!zHddSizes!