0

Can someone help me make the following batch file only process files that are older than 365 days?

@echo off
SetLocal EnableDelayedexpansion

set "Folder=C:\Test Folder"
set "exclude=.dll.exe.bat.zip.jpg.bmp.pdf.mp4.vbs"

FOR /f "delims=" %%x IN ('dir /b /s "%Folder%" ') do if "!exclude:%%~Xx.=!" 
equ "%exclude%" (
"7za.exe" a -sdel -stl "%%~dx%%~px%%~nx.zip" "%%x"
)
Marsi63
  • 49
  • 6
  • 1
    @scientist_7 Thanks for the steer in the right direction using forfiles. I have now been able to answer my own question with your help. – Marsi63 Nov 11 '19 at 17:30

1 Answers1

0
@echo off
color 0A
SetLocal EnableDelayedexpansion

Set folder="C:\Test Folder"

Set exclude=".dll.exe.bat.zip.jpg.bmp.pdf.avi.mpg.mov.mp4.vbs.lnk"

FOR /f "delims=" %%x IN ('forfiles /p !folder! /d -365 /s /c "cmd /c echo @path"') do if "!exclude:%%~Xx.=!" equ "%exclude%" (
      "7za.exe" a -sdel -stl "%%~dx%%~px%%~nx.zip" %%x 
)
Marsi63
  • 49
  • 6