Batch to read USMT size results

N/a / NA
February 5, 2009 at 07:55:18
Specs: Vista,XP, na
Hello I'm trying to do the following.

I have about 1400 folders which represent a computer name. Each folder has a sub folder called USMT3. USMT3 contains a file called usmtsize.txt As shown here :


usmtsize.txt contains the following data
0 16661614
512 16702464
1024 16760832
2048 16883712
4096 17145856
8192 17678336
6384 18808832
32768 21102592
65536 26214400
131072 36700160
262144 57147392
524288 99614720
1048576 186646528

What I am trying to do is create an output file (preferably a .csv so I can import it into excel) that will contain two columns, The computer name, and number from the second column on the 5th row. So from the sample data I've provide I would expect to get a file result.csv that would contain

In order to do this was thinking of using a Forfiles.exe such as

forfiles /m "usmtsize.txt" /s /c "cmd /c echo @path" > temp.txt

the output temp.txt



for the next the step I think i need to use a For /F to read the path file, set a variable for the \computername\ then set a second variable for the result of reading usmtsize.txt and finding the value of of the 4th line and second column.

Then some how this would be outputed to new .csv file

I'm lost as to how the code would look any suggestions would be appreciated

thank you


(USMTSIZE.exe is created by the MS USMT profile migration tool, its used to determine how much storage space is required to store a user profile migration store)

See More: Batch to read USMT size results

Report •

February 5, 2009 at 13:03:16
@echo off > new.csv & setLocal EnableDelayedExpansion

pushd C:\temp\results

for /f "tokens=* delims= " %%a in ('dir/b/ad') do (
set N=0
for /f "tokens=2 delims= " %%s in (%%a\USMT3\usmtsize.txt) do (
set /a N+=1
if !N! equ 5 echo %%a, %%s >> new.csv

If at first you don't succeed, you're about average.


Report •

February 6, 2009 at 06:17:05

Thank you Very very much M2.

After posting my request I started to create a working batch, I quickly abandoned the forfiles.exe. I was using the for /f cmd stumbled on the !dynmaic! variables but I was not able to piece everything together. I would never have figured out the N=0, set /a N+=1 that gets the line counting worked out. I was trying to filter out the proper results with some piping to Findstr.

Because I tried on my own I was "doubly" amazed by your code ! So simple and my comprehension has gone up two fold !


Report •

Related Solutions

Ask Question