With the help of StackOverflow and a number of other places I've created the following script, the purpose is to look at a folder and it's subdirectories, if the files are older than 32 days -> move them to another folder and zip that folder. If the zipped folder is older than 366 days, delete it.
I believe the script works well on a smaller scale with a couple hundred files but the issue I'm facing is there's now 12 months worth of data in these directories that I now need to analyse. There's about 8 folders and an average of 500,000 files in each all around the 1kb - 2kb in size.
Additionally I'm expecting to have an issue where all the files from the last 12 months will be added to the same archive, rather than an individual archive for each date.
What are my options for optimising this? I understand I have probably done this incorrectly.
Script below:
@echo off
if not exist c:\7za920\7za.exe goto end
SET LOGS=C:\logs
SET TEMP=C:\temp
SET ARCHIVE=C:\archive
SET DELETEDARCHIVE=C:\deletedarchive
For /f "tokens=2-4 delims=/ " %%a in ('date /t') do (set mydate=%%c-%%a-%%b)
For /f "tokens=1-2 delims=/:" %%a in ('time /t') do (set mytime=%%a%%b)
ROBOCOPY %LOGS% %TEMP% /move /minage:32 /MT:32
for %%X in (%TEMP%\*.*) do "c:\7za920\7za.exe" a -tzip "%ARCHIVE%\%mydate%_%mytime%_ARCHIVE.zip" "%%X"
ROBOCOPY %ARCHIVE% %DELETEDARCHIVE% /move /minage:366
del %DELETEDARCHIVE% /q