lundi 30 mai 2016

Batch- Use if-else with forfiles recursively

I use forfiles command to check if the files from a directory have the actual date:

forfiles /p C:\copies /s /m *.bak /d 0 
if %errorlevel% == 0 (
  echo OK
) else (
  echo Non OK
  EXIT /%errorlevel%
)

But the if-else statement only works with the last file. If I use the /c parameter it works fine but I can't use the else to do other think:

/c "cmd /c echo @file is outdated." 

What is the best way to use the if-else statement with forfiles?

Aucun commentaire:

Enregistrer un commentaire