Gather File Size and Information

· Windows Scripts

I wrote this one a few years ago. I’m pretty sure there are better ways of doing this, but code samples are always good. Place the below in a *.CMD file to gather information on a certain directory across multiple servers. Replace the “db” directory with a directory of choice to get the information of all the contained child files.

@ECHO OFF
REM Source: http://wp.me/p6h4z-1E
REM This script gathers the names and file sizes of all the
REM files (databases) on the specified servers.
REM - Remove header and footer details
REM - Replace all spaces with comma
REM - Align the Commas
REM - Convert to a *.csv
REM - open in Excel
REM - Remove the date, time and extra spaces
REM - Add Server, Drive (beginning) and Relative Size (end)
REM - Add as relative size: =IF(C2> C:Space.txt
dir \SERVER1D$db /os /-c >> C:Space.txt
dir \SERVER1E$db /os /-c >> C:Space.txt
dir \SERVER1F$db /os /-c >> C:Space.txt
dir \SERVER2C$db /os /-c >> C:Space.txt
dir \SERVER2D$db /os /-c >> C:Space.txt
dir \SERVER2E$db /os /-c >> C:Space.txt
dir \SERVER2F$db /os /-c >> C:Space.txt
dir \SERVER3C$db /os /-c >> C:Space.txt
dir \SERVER3D$db /os /-c >> C:Space.txt
dir \SERVER3E$db /os /-c >> C:Space.txt
dir \SERVER3F$db /os /-c >> C:Space.txt
Notepad.exe C:Space.txt
author image

About Joseph Spurrier

I'm passionate about building solutions to automate tasks and improve efficiency. Tech guy. Traveler. Runner. Guitar player. Scotch and beer enthusiast. Keybase GitHub Gists LinkedIn Twitter

Share this post


Comments powered by Disqus