Solved

findstr dos command need to exclude bytes free

Posted on 2008-10-21
6
1,531 Views
Last Modified: 2011-10-19
From a win32 dos command box we can execute the dir command that shows the total free bytes on disk in the last line:

.....--output omitted--....
 Directory of C:\temp

21/10/2008  12:53    <DIR>          .
21/10/2008  12:53    <DIR>          ..
21/10/2008  12:53                 0 free.txt
               1 File(s)              0 bytes
               2 Dir(s)  142.985.986.048 bytes free


With the findstr command you can exclude string data from a command. I was trying to get the free bytes value from the last line 142.985.986.048 so i can put it in a variable.

Anyone that can help me a bit?

C:\>findstr /R "<<regular expression needed here>" |dir

more info on the findstr win32 command:
http://www.ss64.com/nt/findstr.html
0
Comment
Question by:techneitsolutions
  • 4
  • 2
6 Comments
 
LVL 51

Expert Comment

by:ahoffmann
ID: 22768154
for /f "usebackq tokens=2,3,4" %i in (`dir`) do @if %k==bytes echo %j
0
 
LVL 51

Expert Comment

by:ahoffmann
ID: 22768161
> .. so i can put it in a variable.
for /f "usebackq tokens=2,3,4" %i in (`dir`) do @if %k==bytes set variable=%j
0
 

Author Comment

by:techneitsolutions
ID: 22784380
"k was unexcpected at this time"

0
Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

 
LVL 51

Expert Comment

by:ahoffmann
ID: 22790551
then your dir command returns strange results, it works for the xample given in the initial question
0
 

Author Comment

by:techneitsolutions
ID: 22793933
Well i created two batch files:

example1.bat that holds the first post
example2.bat that holds the second post.

I executed both of them, see results in attached file...
batchfiles.jpg
0
 
LVL 51

Accepted Solution

by:
ahoffmann earned 500 total points
ID: 22803879
> Well i created two batch ..
in batch files you have to double the %
read find help about stupid windoze syntax
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Whatever be the reason, if you are working on web development side,  you will need day-today validation codes like email validation, date validation , IP address validation, phone validation on any of the edit page or say at the time of registration…
As most anyone who uses or has come across them can attest to, regular expressions (regex) are a complicated bit of magic. Packed so succinctly within their cryptic syntax lies a great deal of power. It's not the "take over the world" kind of power,…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…

706 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now