I need to search a folder structure to check if certain folders exist, if they do then need to delete the files in the folders which are 14 days+ old.
Example of folder structure:
Ideally I want to search c:\*.*\letters\ if 'reject' or 'printed' folders exist then delete files older than 14 days in c:\*.*\letter\reject & c:\*.*\letters\printed.
The script structure should be:
1. A FOR statement looping through and searching c:\*.*\letters\
2. IF EXIST 'reject' folder THEN do FORFILES cmd to delete files older than 14 days
3. IF EXIST 'printed' folder THEN do FORFILES cmd to delete files older than 14 days
Some of the code I've been tinkering with, as you can see I'm struggling :\
REM Some code I've been tinkering with
for /d %a in ("c:\*") do echo c:\%a\letters\
if exist c:\%a\letters\reject
forfiles /p c:\*.*\letters\reject\* /s /m*.* /dt-14 /c"cmd /c echo @file"