Batch: check for disk space & Delete folders

September 28, 2010 at 16:22:41
Specs: Windows xp, core2duo / 2gb ram
Hello all i am trying to create a Batch file to check disk space and do the following : if enough space then exit if not enough space delete some folder except some specific folders.

For example :

@echo off
for /f "tokens=3" %%a in ('dir D: /c ^| find /i "bytes free"') do set Free=%%a
if %Free% LEQ

(it checks if the drive has less than 30gb and after i want to execute a command to delete folders to free up space except some specific ones)

i am using D: drive and my folder is D:\games so i want the batch to check D: and if space is lower than 30gb i want it to go to D:\games and delete the folders inside it but not delete specific ones for example the games folder has inside some folders like : world of warcraft, call of duty, age of empires, lineage and many more i dont want to delete for example world of warcraft folder and lineage but i want to delete all the rest folders maybe a .txt file or an .ini file to write there what folder i don't want it to delete ?

i would really appreciate your help i have searched everywhere and i cant find a solution :(

See More: Batch: check for disk space & Delete folders

Report •

September 28, 2010 at 18:45:11
download coreutils for windows then you can use the commands du or df to check for disk space free.

c:\> du -sk
c:\> df

GNU win32 packages | Gawk

Report •

September 28, 2010 at 23:49:06
I got a file server and some computers. I store all the games to my file server at \\server\games. At the other computers the games are been copied at D:\games. i have made a batch file for that because i have my C: drive Frozen with deep freeze so i run a batch file to copy the game from \\server\games to D:\games then run the registry files and then the .exe of the game. This works flawless. The problem is that some games are too big to copy every time and the D: Drive is only 300 gigabyte and i got more that 200 games. so my thought is when disk space is low to delete some games but not the games that are too many gigabyte. for example: world of warcraft 18gigabyte+, lineage and 2-3 other games.

What i want to do :

I want to create another batch file that checks D: for free space and if the space is lower than 30gigabyte to delete folders from D:\games but exclude specific folders i tell it not to delete. Else if the space is more just do nothing and exit. my problem is how to use the rmdir command or any other command to tell it to delete all in D:\games except the folders i specify to a .txt or an .ini ?

Report •

Related Solutions

Ask Question