Support Forums

Full Version: [Batch] Quick Drive Information Script (Created by AceInfinity)
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
Here's a quick script I've been working on for the past 20 minutes. It returns drive information (basic) and allows you the option to export it to a text file in the directory that you ran the script.

[Image: ibcrx8FIm8ohG.png]

Code:
@echo off
title Quick Drive Information
SETLOCAL ENABLEEXTENSIONS ENABLEDELAYEDEXPANSION

call :AppInfo > %windir:~0,2%\drive_info.txt
for %%G in (A B C D E F G H I J K L M N O P Q R S T U V W X Y Z) do (
    fsutil fsinfo drivetype %%G: | find "Fixed" > nul 2>&1 && echo %%G: Drive [Fixed Drive]: >> %windir:~0,2%\drive_info.txt
    fsutil fsinfo drivetype %%G: | find "CD-ROM" > nul 2>&1 && echo %%G: Drive [Removable Drive] >> %windir:~0,2%\drive_info.txt && echo. >> %windir:~0,2%\drive_info.txt
    fsutil fsinfo volumeinfo %%G: | find "File System Name : NTFS" > nul 2>&1 && call :NTFSInfo %%G    >> %windir:~0,2%\drive_info.txt
)
type %windir:~0,2%\drive_info.txt

echo This is the end of the results...
set /p userinput=Would you like to keep these results by creating a file? [Y/N]

if /i "!userinput:~0,1!"=="y" goto Exp
del "%windir:~0,2%\drive_info.txt"
goto :eof

:Exp
echo Exporting data to text file:
echo.      %~dp0drive_info.txt
@move /Y %windir:~0,2%\drive_info.txt %~dp0
goto :eof

:NTFSInfo
for /f "tokens=7 delims=: " %%B in ('fsutil volume diskfree %*:') do (
    echo.   -- FileSystem for drive /%%G: NTFS
    echo.   -- Free Space: %%B bytes
)
echo. && goto :eof

:AppInfo
(
    echo Quick Drive Information - [%Date%]
    echo Developed by AceInfinity 2012
    echo.
)

Enjoy Smile
Looks quite nice Ace, congratulations. See, this is what I like about you. Every second coder knows batch to a certain extent, but I've yet to meet someone who can produce something like this. Well done as usual Ace, now try for a little more detail? Smile
(02-08-2012, 07:34 AM)BreShiE Wrote: [ -> ]Looks quite nice Ace, congratulations. See, this is what I like about you. Every second coder knows batch to a certain extent, but I've yet to meet someone who can produce something like this. Well done as usual Ace, now try for a little more detail? Smile

A little more detail on the drive information? There's lots more I could do lol, but it involves lots of checks, as the built in Microsoft files don't seem like they enjoy dealing with non NTFS filesystem formats.

If you want to know more about how i've made this script and how it works, just ask and i'll walk people through it if there is any questions.
Yeah a little more detail on the Drive Info. Like how much memory there is on the drive, and then how much has been used. Also, maybe something like:
GIG
MB
KB
That would require some WMI namespace's to be queried out. But remember, if I was to do something advanced I wouldn't stick with Batch. It's not a powerful language, so you can't expect it to do everything Smile

There's basically all this information that I can add in there, although, again, only on the NTFS formatted drive volumes.

Code:
Volume Serial Number : 0x80d0af2d
Max Component Length : 255
File System Name : NTFS
Supports Case-sensitive filenames
Preserves Case of filenames
Supports Unicode in filenames
Preserves & Enforces ACL's
Supports file-based Compression
Supports Disk Quotas
Supports Sparse files
Supports Reparse Points
Supports Object Identifiers
Supports Encrypted File System
Supports Named Streams
Supports Transactions
Supports Hard Links
Supports Extended Attributes
Supports Open By FileID
Supports USN Journal

What I did earlier for free space, was just basically parsing out data from an output of something like this:
Code:
Total # of free bytes        : 523995136000
Total # of bytes             : 735331741696
Total # of avail free bytes  : 523995136000

Edit: Also that "Max Component Length : 255" is junk. It's the reason why I hate Microsoft Windows NTFS filesystem, as there's many restrictions with that.
Hmm, yeah it would obviously be much easier to do it in something like VB, C++ or C# but I thought you could give it a go in this haha. Would it be too much work, or is it just not possible?

It would be quite interested to see a batch script do that and see how it would handle it.
I'm sure I could get it to work, but every little small feature you add will slow down the overall script as well keep in mind, and batch is slow for most things Smile
(02-08-2012, 08:19 AM)AceInfinity Wrote: [ -> ]I'm sure I could get it to work, but every little small feature you add will slow down the overall script as well keep in mind, and batch is slow for most things Smile

Yeah, true. I just thought It'd be quite interesting to see how it would pan out. Tongue I haven't see a batch script like this before.

I used to do a little batch like 2 years ago, I forgot most of it now though. All that stupid messaging and making it open like 500+ cmd's. xD

If you really want to count out how many times you write it on a line.

Try this though:
Code:
@for /l %%i in (1,1,500) do ( start )

This will run the start command (open a new console) 500 times.
Ahh, I never new that haha. I did like batch, it was fun to use and quite easy too. But like most of the coding languages I've tried so far, I never went back to it. Unsure
Pages: 1 2