Batch Script to get Disk Usage of Folders Recursively

Rob van der Woude has a nice batch script to get disk usage of folders & subfolders in Windows since there isn’t a built-in function.  This could be similar to Linux du command.
 

@ECHO OFF
:: Use local variables
IF "%OS%"=="Windows_NT" SETLOCAL
:: Check command line arguments and Windows version
ECHO.%1 | FIND "/" >NUL
IF NOT ERRORLEVEL 1 IF /I NOT "%~1"=="/L" GOTO Syntax
ECHO.%1 | FIND "?" >NUL
IF NOT ERRORLEVEL 1 GOTO Syntax
ECHO.%1 | FIND "*" >NUL
IF NOT ERRORLEVEL 1 GOTO Syntax
IF NOT "%OS%"=="Windows_NT" GOTO Syntax
IF NOT "%~1"=="" IF /I NOT "%~1"=="/L" IF NOT EXIST "%~1" GOTO Syntax
SET LongFormat=1
IF /I NOT "%~1"=="/L" IF /I NOT "%~2"=="/L" SET LongFormat=0
:: Go to start directory
SET StartDir=%CD%
IF NOT "%~1"=="" IF /I NOT "%~1"=="/L" SET StartDir=%~1
PUSHD "%StartDir%"
IF ERRORLEVEL 1 GOTO Syntax
:: Display header
ECHO Directory	Space used (MB)
ECHO.=========	===============
:: Display disk usage for start directory
IF NOT EXIST *.* GOTO SubDirs
FOR /F "tokens=3,4*" %%A IN ('DIR %1 /A-D /-C ^| FIND /I "File(s)"') DO SET ListDir=%%A
:: Different procedures depending on /L switch
IF "%LongFormat%"=="1" GOTO LongFormat
SET /A ListDir=%ListDir%+524288
SET /A ListDir=%ListDir%/1048576
ECHO..	%ListDir%
SET ListDir=
GOTO SubDirs
:LongFormat
:: Strip last 6 digits from value
SET ListDir=%ListDir:~0,-6%
IF NOT DEFINED ListDir SET ListDir=0
:: Display resulting value in MB
ECHO..	%ListDir%
:: Clear variable
SET ListDir=
:: Display disk usage for every subdirectory
:SubDirs
FOR /D %%A IN (*.*) DO CALL :List%LongFormat% "%%~A"
:: Done
POPD
GOTO End
:List0
:: Set variable value to bytes used by directory
FOR /F "tokens=3,4*" %%B IN ('DIR /A /-C /S "%~1" ^| FIND /I "File(s)"') DO SET ListDir=%%~B
:: Add 0.5MB in order to properly round the value when integer divided by 1MB
SET /A ListDir=%ListDir%+524288
:: Integer divide by 1MB
SET /A ListDir=%ListDir%/1048576
:: Display resulting value in MB
ECHO.%~1	%ListDir%
:: Clear variable
SET ListDir=
GOTO:EOF
:List1
:: Set variable value to bytes used by directory
FOR /F "tokens=3,4*" %%B IN ('DIR /A /-C /S "%~1" ^| FIND /I "File(s)"') DO SET ListDir=%%~B
:: Strip last 6 digits from value
SET ListDir=%ListDir:~0,-6%
IF NOT DEFINED ListDir SET ListDir=0
:: Display resulting value in MB
ECHO.%~1	%ListDir%
:: Clear variable
SET ListDir=
GOTO:EOF
:Syntax
ECHO.
ECHO DiskUse, Version 5.01 for Windows 2000 / XP
ECHO Display disk space used by subdirectories (tab delimited)
ECHO.
ECHO Usage:  DISKUSE  [ startdir ]  [ /L ]
ECHO.
ECHO Where:  "startdir"  is the directory containing subdirectories to be
ECHO                     inventoried (default is the current directory)
ECHO         "/L"        is used for large numbers, over 2GB, to prevent return
ECHO                     of negative numbers due to batch math limitations
ECHO                     (integer division by 1000000 instead of properly
ECHO                     rounded mathematical division by 1048576)
ECHO.
ECHO Written by Rob van der Woude
ECHO http://www.robvanderwoude.com
:End
IF "%OS%"=="Windows_NT" ENDLOCAL

Tool: AutoLogon – Configure Windows' Automatic User Logon

What is it?

I created a small tool to help facilitate setting the default user to automatically logon to a system.

Requirements

  • Administrator Privileges
  • .NET 2.0 or greater

Details

There are 4 registry entries of interest here:

[HKEY_LOCAL_MACHINESOFTWAREMicrosoftWindows NTCurrentVersionWinlogon]
AutoAdminLogon=1
DefaultUserName=
DefaultPassword=
ForceAutoLogon=1

If you don’t want to download and run my program, you can simply copy the above text into notepad, save-as a .reg file and double-click it to run it. Make sure you take care to modify the settings as necessary.
The convenience of my application is that it will list local users so you can simply just click on the desired user and set the information accordingly.

Screenshots

2013-01-30_092244

Download

Download from here:  AutoLogon (62KB)

Changelog

  • 1/30/2012 – Added Show/Hide for password box and set default to hide password.
  • 1/29/2012 – Initial Release for Testing

Yawcam Viewer

I am working on a Motion-JPEG stream viewer for the Yawcam webcam streaming software.  This allows you to enter your stream’s URL and choose the size for the display and it will stream the Motion-JPEG (MJPG) using Aforge’s Video library since I’m not writing a parser for the MJPG stream in VB.net.

Here’s a screenshot of the current version I’m working on.  Everything is working and I’m now starting to test the authentication portion.
 
Here’s a video walkthrough of the progress I’ve been making.


Hopefully this will be built upon and offer a nice alternative to the browser based viewing of the live stream for Yawcam software.

This is being developed in Visual Basic 2010 Express and is currently tested to run on XP SP3, Windows 7 (32 and 64bit) and Windows Vista (32 and 64bit).  It will require .NET framework 4 but I have built the first prototype with .NET 2 and it worked fine.

GooglePlus RSS Feed Reader in PHP

I’m working on a GooglePlus RSS Feed Reader in PHP for anyone who might be interested in making a WordPress module or something similar to display N latest Public posts to your stream.

I have some code in PHP that I’m tinkering with. The original idea came from http://plusfeed.appspot.com/.

You can view the progress: https://techish.net/pub/googleplus_rss.php

You can use ?id= to supply your own Google+ ID string found when you login and navigate to http://plus.google.com/

The string of interest here is:

https://plus.google.com/_/stream/getactivities/?&sp=[1,2,"XXX",null,null,null,null,"social.google.com",[]]

Where XXX is your Google+ ID.

[update: August 7, 2011 22:45 EST]

The RSS is for the most part complete; I have some code clean-up to work on yet but it is working. Check out the right column and you’ll see my public feed from Google+.

To reference this, simply add: https://techish.net/pub/googleplus_rss.php?id=YOURGOOGLEPLUSIDHERE to the RSS widget source in WordPress – or in your favorite RSS reader. Let me know if you have any problems!

Tip: You can show the latest N by adding ?latest=X to the URI.

[update: August 6, 2011 02:07 EST]

I have completed most of the work. I’ve added two user controllable parameters:

id - Integer:  Google+ ID
latest - Integer:  Latest X number of entries to return.

https://techish.net/pub/googleplus_rss.php?latest=5 will show you my latest 5 entries.

I plan to add date constraints sometime soon and eventually I can maybe pull in comments to the entries(?).

JavaScript Operating System

I knew it had to exist (laughing out loud), and I just found it.  A JavaScript operating system.  Anyone who knows me knows that I joke around about “creating a new operating system coded in JavaScript”… well, here it is:  JS/UIX

JS/UIX is an UN*X-like OS for standard web-browsers, written entirely in JavaScript (no plug-ins used). It comprises a virtual machine, shell, virtual file-system, process-management, and brings its own terminal with screen- and keyboard-mapping.

JS UX/UI
JS UX/UI Command Example

You can give JS/UIX a try here:  http://www.masswerk.at/jsuix/