1.

Solve : Help in creating a batch file?

Answer»

I am using W7 Ultimate.
I wish to create a batch file that will;

1. measure  the free space on HDD D:, and if less that 50GB delete the oldest folder named LIKE "Fri 04.23.2010"

2. Do an image backup to Drive D:

3. Rename the image BU folder to a name like that in step 1.

I already have the command for step three.
The 50GB should be able to be changed through editing.
For step 1, INSTEAD of measuring free space, the number of folders could be counted and remove the oldest folder if the count exceeds a certain number, again editable. Quote from: blockie on April 24, 2010, 08:12:48 PM

I am using W7 Ultimate.
1. measure  the free space on HDD D:, and if less that 50GB delete the oldest folder named like "Fri 04.23.2010"


Here is a start for checking free space:


C:\>fsutil volume diskfree C:
Total # of free bytes        : 300346417152
Total # of bytes             : 319965622272
Total # of avail free bytes  : 300346417152

C:\>

C:\>E:

E:\>fsutil volume diskfree E:
Total # of free bytes        : 139043950592
Total # of bytes             : 160039239680
Total # of avail free bytes  : 139043950592

E:\>

I use Win 7.  The fsutil command should be available for XP.
Need to be The system Administrator  for Win 7Hello,
what you want to do in batch is not really very hard. RATHER than ask why you didn't just go ahead and do it yourself I'm going to ask you some of the questions about your idea.
First of all, are you really sure this is a valid idea? Is this the sort of thing you really want your computer to do automatically? Why?
The information you have given is not complete for a real world application using batch file, or for that matter, any other type of common programming method.
There are major flaws either of mission or design. Here's one example of what WILL go wrong. A certain folder is DELETED , only because it's the oldest folder. How can you be sure that it's not a folder that would have critical information in it that should not be deleted? Further, how do you know that deleting the oldest folder would resolve the issue of freeing up more than 50 GB on the hard drive? Do you understand that deleting a folder may not free up disk space? Even if the folder was not empty?.
Also, what should the PROGRAM do if there is FAILURE or if something does not go as planned? Should it stop the process? Should WAIT for human to intervene? If a human was available at all times, why even use a batch program to do this?
Sorry, but I don't like the idea of just nuking some folder because it's old and there is a limited amount of disk space. Unless it's done by a human.


Discussion

No Comment Found