I have this batch that get the free space about the devices that my system has and the name of they (C:\, D:\, etc).
for /f "tokens=2 delims==" %%I in (
'wmic LOGICALDISK get FreeSpace /format:list 2^>NUL'
) do (sqlcmd -v varSpace="%%I" column="FIELD1" -i C:\cmdutils\test.sql)
for /f "tokens=2 delims==" %%U in (
'wmic LOGICALDISK get name /format:list 2^>NUL'
) do (sqlcmd -v varSpace="%%U" column="FIELD2" -i C:\cmdutils\test.sql)
The sql file does an insert:
USE [BBDD_SYSTEM]
INSERT INTO SYS_TABLE ($(column)) VALUES ('$(varSpace)')
The problem is the first for loop insert 3 rows (I have 3 disks) with the free space and the second loop insert 3 rows more with the name, total 6 rows
The correct operation is 3 rows in total with the space and name.
How can I join the two loops?