The best VPN 2024

The Best VPS 2024

The Best C# Book

A little coding challenge for doing image backups

Spread the love

you can use the first one to set variable %FreeSpace% to be the free space in bytes.

Since Im not all that great at writing scripts, I fear I cannot help more.

Another alternative might be to research if 64 bit powershell could run said batch file better. Problems with that are that as far as quick look goes, powershell has script execution disabled as default for security reasons.

Batch files and their variables dont really like 64 bits (and you cant get 1TB with 32 bit)

m0lpeterh337July 27, 2016 8:30:21 AM

you can compare that to 1TB (1024*1024*1024*1024=1,099,511,627,776)

forfiles -p C:\what\ever -s -m *.* /D -number of days /C cmd /c del @path

You could probably get around that 32 bit problem by assuming that anything over 1,000,000,000,000 is close enough to 1TB and thus just count characters in %FreeSpace% string to see if there are 13 or more. (12 or less would be 999GB or less)

m0lCant find your answer ? Ask !Get the answerUSAFRetJuly 27, 2016 8:16:47 AM

m0lCant find your answer ? Ask !PublishAsk the communityTags

So unless better alternative can be found, assuming that backup is around 500GB and you have space for 6 (totals to 3TB) you could just go for the delete older than 6 weeks route.

In short.. the ways to get around the problem exist.

:: Preserve only the %MAXBACKUPS% most recent backups.

Although that assumes each backup is in its own subfolder but by altering the dir command and switching rd to del, you could change it to work with files.

and if it is less, delete oldest file. (assuming 1/week so as you said, older than 6 weeks)

Example: Notebook, Android, SSD hard drive

or.. googling a bit more, use ready script from:

more specific examples can be found by googling batch file for whatever you want to do

Edit: Also the macrium reflect supports creating rescue media, which as far as I assume, if created on target machine, includes all necessary sata/raid/other drivers.

Leave a Comment