I'm working with a batch file to delete archived documents older than 14 days, and I'm calling the file from an automation process (Lansa Composer) that reads the return code of the script to see if there was a problem. Here's the script:
@echo off
@Echo Deleting files older than 14 days...
cd /d C:\Windows\System32
FORFILES /P "[file path...]\IDOC_ARCHIVE" /M *.* /D -14 /C "cmd /c del @file"
The issue is that the script returns an error code and prints "ERROR: No files found with the specified search criteria" if it doesn't find any files to delete, when I really only want it to return an error if there is a problem accessing the directory or running the del command, etc. Is there some way I can get this script to suppress the "no files found" error, but allow others to pass through?
After some Googling I tried the solutions on this page, but they won't work for what I want, since in the first case it suppresses ALL errors, and in the second the text of the error message is passed, but the actual return code is still suppressed (which is what the automation process reads).