Solved

findstr dos command need to exclude bytes free

Posted on 2008-10-21
6
1,544 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
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I have been reconstructing a PHP-based application that has grown into a full blown interface system over the last ten years by a developer that has now gone into business for himself building websites. I am not incredibly fond of writing PHP code o…
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…

820 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