I have a batch script that downloads files from my ftp.
It has a section that takes today's date to pull the right files from the server:
FOR /F "TOKENS=1* DELIMS= " %%A IN ('DATE/T') DO SET CDATE=%%B
FOR /F "TOKENS=1,2 eol=/ DELIMS=/ " %%A IN ('DATE/T') DO SET mm=%%B
FOR /F "TOKENS=1,2 DELIMS=/ eol=/" %%A IN ('echo %CDATE%') DO SET dd=%%B
FOR /F "TOKENS=2,3 DELIMS=/ " %%A IN ('echo %CDATE%') DO SET yyyy=%%B
SET yy=%yyyy:~-2%
SET filename=%yy%%mm%%dd%
I run this script every week.
Now I'd like to add a section to the script that would automatically delete files that were downloaded 2 weeks ago.
How do I generate a new variable oldfilename
that would be the formatted today minus 14 days
?