-4

I'm trying to write a batch file that would kinda go like this:

if DiskSpace > 255MB for C:, goto 1
:1
copy "E:\file.txt" "C:\destination\"

It's for a program I assembled, and I needed to create an installer for my employees.

Is this possible? If my description is too vague, I'll explain a bit more:

I'm trying to get a batch file to do certain commands depending on how much free space is available on the C: drive.

Any help will be greatly appreciated.

P.S. The OS is XP.

P.S.S I would also like everything to be in one batch script file, preferably not multiple files.

1
  • 3
    Ancient! XP is long out of support, and modern Windows has Powershell for this stuff. Aug 30, 2015 at 17:14

1 Answer 1

0

Using a plain old batch file for this is going to prove tedious and cumbersome. Instead consider doing your script in something like VBscript (included in XP) or Powershell (probably would require installation). Rough VBscript example:

Dim fso, drv

Set fso = CreateObject("Scripting.FileSystemObject")
Set drv = fso.GetDrive("C:")

IF drv.FreeSpace / (1024 *1024) > 255 Then
     '
     '  Do some useful stuff here
     '
     wscript.echo drv.FreeSpace / (1024 * 1024) 
End If

See https://msdn.microsoft.com/en-us/library/czxefwt8(v=vs.84).aspx for some examples of 'useful stuff' (such as the Copy, Move and Delete methods).

1
  • Thank you, Brandon. This is the answer I was looking for!
    – Tanui
    Aug 31, 2015 at 4:31

Not the answer you're looking for? Browse other questions tagged .