0

I have done a small *.bat file which the following command exists:

forfiles /p %sourcedir% /m *.* /c "cmd /c echo @path && if /l @fdate == %date% (echo true) else (echo false)"

The above checks whether file's modified date is today or not.

I am getting the error after I run it

09/02/2017 was unexpected at this time. 29/01/2018 was unexpected at this time. 13/08/2018 was unexpected at this time.

Note, in the %sourcedir% I have one file that matches the criteria.

1 Answer 1

0

Forfiles default /M searchmask is *, so it can be omitted.

Forfiles also had a /D date argument, where date can be a date or a the current date plus 'dd' days. Using /D 0 would be today.

This reduces the batch file command to:

forfiles /p %sourcedir% /d 0 /c "cmd /c echo @path"

Note: only files that match the condition will be echoed.

1
  • 1
    It would be helpful to add further detail to this answer, explain what the commands you are suggesting do, and how they solve the problem at hand.
    – zeel
    Aug 13, 2018 at 15:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.