Computing.Net > Forums > Programming > Batch to read USMT size results

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Batch to read USMT size results

Reply to Message Icon

Name: naimc
Date: February 5, 2009 at 07:55:18 Pacific
OS: Vista,XP
CPU/Ram: na
Product: N/a / NA
Subcategory: Batch
Comment:

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 :

.\ComputerNameXXXX\USMT3\usmtsize.txt

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
Computername,17145856

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

contains

"C:\temp\results\Computername\USMT3\usmtsize.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

Naim.

(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)




Sponsored Link
Ads by Google

Response Number 1
Name: Mechanix2Go
Date: February 5, 2009 at 13:03:16 Pacific
Reply:

@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.

M2


0

Response Number 2
Name: naimc
Date: February 6, 2009 at 06:17:05 Pacific
Reply:


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 !

Naim.


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: Batch to read USMT size results

Batch to read data and output www.computing.net/answers/programming/batch-to-read-data-and-output/13630.html

Batch to compare files' size www.computing.net/answers/programming/batch-to-compare-files-size/17428.html

batch file to read all lines from txt file www.computing.net/answers/programming/batch-file-to-read-all-lines-from-txt-file-/19834.html