1

I am trying to use batch to check if file was modified today.

Can you please help me with your suggestions? Below is the code with which I am facing some issue.

SET filename="D:\empty\xyz.txt"
forfiles /m %filename% /d 0 && (
    echo The file was modified today
) || (
    echo The file has not been modified today
)
jscott
  • 24,484
  • 8
  • 79
  • 100
user193592
  • 11
  • 1

1 Answers1

0

You can't include a path within the /M search mask. You need to use the /P path argument.

C:\> REM This does not work
C:\> SET FILENAME=D:\empty\xyz.txt
C:\> FORFILES /M %FILENAME%
ERROR: Files of type "D:\empty\xyz.txt" not found.

C:\> REM This does work
C:\> SET FILENAME=xyz.txt
C:\> FORFILES /P "D:\empty" /M %FILENAME%
"xyz.txt"

Please see the Forfiles documentation for more details.

jscott
  • 24,484
  • 8
  • 79
  • 100