Jump to content


 


Register a free account to unlock additional features at BleepingComputer.com
Welcome to BleepingComputer, a free community where people like yourself come together to discuss and learn how to use their computers. Using the site is easy and fun. As a guest, you can browse and view the various discussions in the forums, but can not create a new topic or reply to an existing one unless you are logged in. Other benefits of registering an account are subscribing to topics and forums, creating a blog, and having no ads shown anywhere on the site.


Click here to Register a free account now! or read our Welcome Guide to learn how to use this site.

Photo

Is there any easy way to extract this?


  • Please log in to reply
2 replies to this topic

#1 hackman2007

hackman2007

  • Members
  • 28 posts
  • OFFLINE
  •  
  • Local time:08:38 PM

Posted 12 September 2011 - 06:54 PM

I'm trying to make my life a little easier when doing drive space analysis.

What I want to do is take the output from a simple dir command (this is on a Windows platform, no Unix is involved). I want it to take the "Directory of C:\" and the "# bytes free" part of the output (and would be much easier if it would just auto-convert to GB with two decimal points).

Outside of simply copying/pasting, I haven't figured out a way to do this easily.

Anyone know of a way to do this? It doesn't have to be complicated, I'm not looking for a standalone program or anything like that, just a way to get the output without having to do a lot of clicking. It's all in the same format for all the drives, so formatting shouldn't be too big of an issue.

Edited by hackman2007, 12 September 2011 - 06:54 PM.


BC AdBot (Login to Remove)

 


#2 Didier Stevens

Didier Stevens

  • BC Advisor
  • 2,707 posts
  • OFFLINE
  •  
  • Gender:Male
  • Local time:03:38 AM

Posted 13 September 2011 - 03:03 PM

You can select output from a command with the findstr command.

Example: dir c:\ | findstr /i "free"
This will select all the lines with the word free in it.
You can also save the output of this command directly to a file, like this: dir c:\ | findstr /i "free" > result.txt
Watch out: result.txt will be overwritten each time you execute the command.
To append the output to the file in stead of overwriting it, use >> like this: dir c:\ | findstr /i "free" >> result.txt

Didier Stevens
http://blog.DidierStevens.com
http://DidierStevensLabs.com

SANS ISC Senior Handler
Microsoft MVP 2011-2016 Consumer Security, Windows Insider MVP 2016-2019
MVP_Horizontal_BlueOnly.png

 

If you send me messages, per Bleeping Computer's Forum policy, I will not engage in a conversation, but try to answer your question in the relevant forum post. If you don't want this, don't send me messages.

 

Stevens' law: "As an online security discussion grows longer, the probability of a reference to BadUSB approaches 1.0"


#3 hackman2007

hackman2007
  • Topic Starter

  • Members
  • 28 posts
  • OFFLINE
  •  
  • Local time:08:38 PM

Posted 14 September 2011 - 03:35 PM

You can select output from a command with the findstr command.

Example: dir c:\ | findstr /i "free"
This will select all the lines with the word free in it.
You can also save the output of this command directly to a file, like this: dir c:\ | findstr /i "free" > result.txt
Watch out: result.txt will be overwritten each time you execute the command.
To append the output to the file in stead of overwriting it, use >> like this: dir c:\ | findstr /i "free" >> result.txt


Thanks for the response!

I did successfully try using your method (similar to dir c:\ | findstr /i "free"), but eventually found a much more elegant solution by using this VBS: http://myitforum.com/cs2/blogs/dhite/archive/2006/12/04/vbs-script-to-create-a-server-disk-space-report-to-excel.aspx




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users