Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win


Batch Command for Folder sizes

Posted on 2004-10-26
Medium Priority
Last Modified: 2009-10-08
I am creating a batch file for moving a few folders for safe keeping, and i'm need to have it send me a net send with the folder sizes if possible, so i can,

1. know when the copy is finished.
2. check that it copied everything.

Is there an easy command to do this, I would like to learn WSH but I dont have the time to learn it to implement this.

and can information like this be piped to a net send?
Question by:mesach
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
  • 2

Expert Comment

ID: 12414354
>"I am creating a batch file for moving a few folders for safe keeping"
>" check that it copied everything."

Do you want to copy or move?

Author Comment

ID: 12414384
Im using Xcopy with the Switches /E /H /K /R /V /Y, If there are better ones let me know.

Expert Comment

ID: 12414507
No, I think XCOPY is the best to use here.

I'm gradually working out how to get the dir size at the moment for you, I'll get back to you soon. :)

NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!


Accepted Solution

gilbar earned 2000 total points
ID: 12414586
if you have access to the Resource Kit, its DirUse  command will give you folder sizes.

DIRUSE displays a list of disk usage for a directory tree(s). Version 1.20

DIRUSE [/S | /V] [/M | /K | /B] [/C] [/,] [/Q:# [/L] [/A] [/D] [/O]] [/*] DIRS

/S      Specifies whether subdirectories are included in the output.
/V      Output progress reports while scanning subdirectories.  Ignored if /S is
/M      Displays disk usage in megabytes.
/K      Displays disk usage in kilobytes.
/B      Displays disk usage in bytes (default).
/C      Use Compressed size instead of apparent size.
/,      Use thousand separator when displaying sizes.
/L      Output overflows to logfile .\DIRUSE.LOG.
/*      Uses the top-level directories residing in the specified DIRS
/Q:#    Mark directories that exceed the specified size (#) with a "!".
        (If /M or /K is not specified, then bytes is assumed.)
/A      Specifies that an alert is generated if specified sizes are exceeded.
        (The Alerter service must be running.)
/D      Displays only directories that exceed specified sizes.
/O      Specifies that subdirectories are not checked for specified size
DIRS    Specifies a list of the paths to check.

Note:   Parameters can be typed in any order. And the '-' symbol can be
        used in place of the '/' symbol.

        Also, if /Q is specified, then return code is ONE if any directories are
 found that
        exceed the specified sizes.  Otherwise the return code is ZERO.

Example: diruse /s /m /q:1.5 /l /* c:\users

Author Comment

ID: 12414956
Gilbar that looks like it might work for me, but I cannot seem to make it give me the size of the files in the top level dir,

diruse /S /, /* C:\Test2


    Size  (b)  Files  Directory
          650      2  C:\TEST2\New Folder
          650      2  SUB-TOTAL: C:\TEST2\New Folder

          650      2  TOTAL: C:\TEST2\New Folder

there should be 4 files total

also the directorys im working with are about 6-10 gig with lots of files, and i cannot seem to keep this from being verbose.

BTW thanks for all the help

Author Comment

ID: 12415022
also the dir C:\test1 returns an error(the syntax) because there are no directorys within that folder.

I would have thought there would have been an easy way to get the folder properties

Expert Comment

ID: 12415125
i think that's 'cause you're using the /* switch, you could try is with just the /s. We use it for a monthly size check to see which departments are showing too much inflation and instead of using the /s we generate a diruse for each of the dept folders.  
ps, you're welcome :)

Author Comment

ID: 12415218
Well that gets me the info i need you get the points, now i can go on to getting it to send that to me in a net send! THANKS

Expert Comment

ID: 12415258
glad to help!  the resource kit rocks!  I don't know how i'd be able to do my job without it.  Now I can get back to my work ( let me know if you need a vbscript to return the members of all the global groups that are members of a particular domain local group, 'cause i made one today :)

Featured Post

Veeam Disaster Recovery in Microsoft Azure

Veeam PN for Microsoft Azure is a FREE solution designed to simplify and automate the setup of a DR site in Microsoft Azure using lightweight software-defined networking. It reduces the complexity of VPN deployments and is designed for businesses of ALL sizes.

Question has a verified solution.

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

TOMORROW TOMORROW.BAT is inspired by a question I get asked over and over again; that is, "How can I use batch file commands to obtain tomorrow's date?" The crux of this batch file revolves around the XCOPY command - a technique I discovered w…
Being a system administrator some time we require to do things remotely, one of them is installing software. Here I am going to tell you how to install software through wmic (Windows management instrument console). I am not at all saying that this i…
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
Loops Section Overview

597 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