windows batch file help

B

Bill

Long story short, I am creating a batch file to extract the Volume Serial
Number off the computer, and place ONLY the serial number into a text file.
I start by running the following command from CMD.exe

dir | find /I "serial"

That command returns the following:

Volume Serial Number is 5555-5555

How can I extract or echo ONLY the 5555-5555 to a TXT file from the command?
 
J

jj

Long story short, I am creating a batch file to extract the Volume Serial
Number off the computer, and place ONLY the serial number into a text file.  
I start by running the following command from CMD.exe

dir | find /I "serial"

That command returns the following:

Volume Serial Number is 5555-5555

How can I extract or echo ONLY the 5555-5555 to a TXT file from the command?

dir | find /I "serial" > c:\temp\serial.txt
 
J

jj

dir | find /I "serial" > c:\temp\serial.txt

Oh - I read your post wrong - you only want the number, correct? You
could use gawk to parse the output but that would require you to
download that tool.
 
P

Pegasus \(MVP\)

Bill said:
Long story short, I am creating a batch file to extract the Volume Serial
Number off the computer, and place ONLY the serial number into a text
file.
I start by running the following command from CMD.exe

dir | find /I "serial"

That command returns the following:

Volume Serial Number is 5555-5555

How can I extract or echo ONLY the 5555-5555 to a TXT file from the
command?

Here is how you do it in a Windows batch file:
@echo off
for /F "tokens=5" %%a in ('dir c:\ ^| find /i "volume serial"') do set
Serial=%%a

Best to copy & paste Line 2 in order to avoid typing errors.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top