1

I am trying see how many files how been updated today. So I am running:

forfiles /P C:\Directory\ /S /D %DATE:~4,10% | wc -w 

now I am trying to set the result to a variable but cant' seem to get it work with:

@echo off set files=forfiles /P C:\Directory\  /S /D %DATE:~4,10% | wc -w

when I use echo "%files%" I get : %files% as output.

Anyone know what I am doing wrong. I am new to cmd coming from unix.

1 Answer 1

1
@echo off 
for /f %%c in ('forfiles /P C:\Directory\  /S /D %DATE:~4,10% ^| wc -w') do set files=%%c
echo %files% found

(untested)

Sign up to request clarification or add additional context in comments.

3 Comments

%%c was unexpected at this time. is the error I get
this might be because of %DATE% but I am not sure.
This is a batch file. If you are executing directly from the prompt, change %%c to %c throughout

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.