1.

Solve : Get folder Size??

Answer»

Hello, I've read your forums a bit recently and they've been quite helpful with some problems, however I still have a few.

I'm trying to find out the size of a folder using MSDOS, and also how to subtract two numbers. (Possibly a daft question, but I cant do it)


If it helps to know why I want to know, its because I've written a batch script to backup a server daily, and I want to check if the folder will fit onto the drive before I delete the old backup and replace it, only to find it gets a disk full error part way through.

All i plan on doing is getting the remaining SPACE (which I already have done), add thesize of the backup I'm deleting, to find the total space I'll have available. Then get the size of the new data, and subtract the new data from the space available, and if it's under 10gig email a warning, and 0 or less to email saying it won't manage and so hasn't backed up the files. (I've got the emailing sorted)

Thanks There's probably an easier way, but in a DIR command, you can get the total size of the directory in bytes...in the resource kit, there's a tool called diruse.exe...also usefulThe DIRUSE tool suggested by Ghostdog is the easiest way, and it is a great tool. You could get the total space used with the DIR command, but assuming there are sub directories that need to be calculated, you will probably need to use the DIR /-C command in a FOR /F loop and add the totals up.

If DIRUSE won't work for you then let us know and we will help you with a script that will add all the subdirectories together for you.

To subtract two numbers, try this:
Code: [SELECT]@echo off
set Num1=1234
set Num2=200

set /a Result=%Num1% - %Num2%
echo %Num1% - %Num2% = %Result%DIRUSE worked great thanks. I GUESSED i was doing something WRONG with the subtraction, I'd just tried to echo the actual calculation rather than saving the result and echoing that.
No wonder it didn't work

Thanks for your help



Discussion

No Comment Found