Solved

findstr dos command need to exclude bytes free

Posted on 2008-10-21
6
1,556 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

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

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…
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…
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…

626 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