0

I'm using

    wmic qfe get HotFixID >> WindowsUpdateVersion.txt

in order to export a list of KB{num}. I am looking for a command to reshape this list in many columns (3 or 4 columns, .txt or .xls, not important). I have already tried with

   wmic qfe get HotFixID /format:* >> WindowsUpdateVersion.txt

* (every WMIC Stylesheets)
but none of them seem to work properly.
Any ideas?
Thanks so much!

Matteo
  • 3
  • 1
  • what means not work properly?see the available formats here: http://ss64.com/nt/wmicstylesheets.html – npocmaka Aug 24 '15 at 12:33
  • 'not work properly' means that none of the commands in the link you posted ( ss64.com/nt/wmicstylesheets.html) generates a .txt with more than one column. Thanks – Matteo Aug 24 '15 at 12:37
  • 1
    On my screen the first two items are not in a format to place into columns. `KB2899189_Microsoft-Windows-CameraCodec-Package` and `KB2868626` – foxidrive Aug 24 '15 at 12:41
  • Hi foxidrive. I am working on a workstation without camera, so I do not have a CameraCodec-Package. When I run my code, I obtain about 300 strings, 9 chars each. – Matteo Aug 24 '15 at 12:52

1 Answers1

0

EDITED: to process any trailing lines of less than full lines

This creates file.txt with the ascii data and then writes file2.txt with the 4 columns.

Any lines containing ! will be wrong - if someone wants to apply this in another situation.

@echo off
(
 for /f "skip=1 delims=" %%a in ('wmic qfe get HotFixID') do (
   for /f %%b in ("%%a") do echo %%~b
 )
)>file.txt

setlocal enabledelayedexpansion
set a=
set c=
(
 for /f "usebackq delims=" %%a in ("file.txt") do (
  set a=!a! %%a
  set /a c+=1
  if !c! EQU 4 (
     echo !a:~1!
     set a=
     set c=
  )
 )
if not "!a!"=="" echo !a:~1!
)>file2.txt
foxidrive
  • 40,353
  • 10
  • 53
  • 68
  • @Matteo - No, there is a bug. It is not printing out the last line if it contains fewer than 4 entries. I believe it is a delayedExpansion issue, but there may be more to the story. Also, the ID widths may not be constant, so the columns may become misaligned. – dbenham Aug 24 '15 at 19:28
  • @dbenham you are right: I confirm the issue about the last line! The misaligned it is not relevant if you import the file in excel – Matteo Aug 25 '15 at 06:20
  • @dbenham Thanks for pointing out the bugs - I reused 2007 code which had a specific set of data and didn't study it to see that limitation. I've replaced the code after testing it here briefly. – foxidrive Aug 25 '15 at 06:39
  • @Matteo Sorry about the bugs - mea culpa. Try the version above. – foxidrive Aug 25 '15 at 06:45