I scripted the following batch file.
It's purpose, is to make space for the new files to be archived to the archive drive.
I do this by comparing the working folder with it's corresponding folder in the mirror drive.
I have two problems here:
-Primero, I just came back from a very cool vacation and I'm brain challanged.
-Secundo, My archive drive is 2TB and the math involved is greater than 2147483647 bytes (32bites).
I need to make this script work considering the DOS 32bits limit.
Please remember. I'm currently brain challanged. So please do not provide ideas, but rather help me by completing my script since I need this kind of pronto.
Thanks for your help,
MODE CON: COLS=150 LINES=60
REM SETTING VARIABLES
ECHO ^>SETTING VARIABLES
REM READING FILES TO BE ARCHIVED BY COMPARING THE WORKING FOLDER WITH THE MIRROR FOLDER
FOR /F "tokens=2 delims= " %%A IN ('Robocopy "%BaseMirror%\%BaseFolder%" "%BaseSource%\%BaseFolder%" *.* /MIR /L /NJH /NJS /NS /NDL /XF "*RECYCLER*" "desktop.ini" "Thumbs.db" ".~*.*" "*.*#" "~*.*" "*.swp" "*.dmp" "*.tmp" "pagefile.sys" "hiberfil.sys" /XD "RECYCLER" ^| Findstr -V ^*') DO (
SET /a TotalFileSize=!TotalFileSize! + %%~zA
REM Reading free space available on archive drive
FOR /F %%A in ('wmic logicaldisk where "DeviceID='%ArchiveDrive%'" get FreeSpace ^| FINDSTR /R ') DO SET FreeSpace=%%A
REM Deleting old archive files up to the required space needed for the new archives
IF %FreeSpace% LEQ %TotalFileSize% (
FOR /F "delims=" %%B IN ('DIR /s /b /od /a-d *.* ^| FINDSTR /i "%ArchiveDrive%"') DO (
DEL /f /q "%%~fB"
SET /a FreeSpace=!FreeSpace! + %%~zB
ECHO !FreeSpace! %TotalFileSize% "%%~fB"
) ELSE (
ECHO There is sufficient storage space available to receive the new archive files.
ECHO Deleting old archives is not required
IF %FreeSpace% LEQ %TotalFileSize% EXIT /b