1

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
hylian
  • 131
  • 3

1 Answers1

0

I did a script that do like you did, but I directly used 7zip move command into a zip named by the day.

So it calculate the day minus 30, and get all corresponding file for that day. You can mod the vbs as you wish to get all day from past 12 months.

Get it there (the output to IE was just a bonus in the script); https://gallery.technet.microsoft.com/Archiving-VBS-script-with-b0f21ddc

I used it with some security camera in industry, which save a bunch of .jpg in their folder, with really big file count like you.

yagmoth555
  • 16,300
  • 4
  • 26
  • 48