Solved

findstr dos command need to exclude bytes free

Posted on 2008-10-21
6
1,540 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
ScreenConnect 6.0 Free Trial

Discover new time-saving features in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI, app configurations and chat acknowledgement to improve customer engagement!

 
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

Is Your AD Toolbox Looking More Like a Toybox?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

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

by Batuhan Cetin Regular expression is a language that we use to edit a string or retrieve sub-strings that meets specific rules from a text. A regular expression can be applied to a set of string variables. There are many RegEx engines for u…
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…
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…

773 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