Page 1 of 1

Problem with set /A

Posted: 04 Jan 2012 12:34
by tmboredi
Hi guys,

Is there something wrong with my set statement? I'm getting "The system cannot find the file specified."
But dir /a /s /OG D:\FYP\piclog |find /v "<DIR>" | find /c "M" alone returns a proper integer value, 21 etc.



set /A count="dir /a /s /OG D:\FYP\piclog |find /v "<DIR>" | find /c "M""

echo.%count%

Re: Problem with set /A

Posted: 04 Jan 2012 13:50
by aGerman
Use a FOR /F loop to receive a value from a command line:

Code: Select all

for /f %%i in ('dir /a /s /OG D:\FYP\piclog |find /v "<DIR>" ^| find /c "M"') do set /a count=%%i

Regards
aGerman

Re: Problem with set /A

Posted: 05 Jan 2012 10:15
by tmboredi
Thanks! but my command prompt window closes right after it runs, even with a pause at the end. Any idea what is wrong?

EDIT: It says | was unexpected at this time. :?

Re: Problem with set /A

Posted: 05 Jan 2012 11:29
by Squashman
Missing a Carrot before the first pipe.

Re: Problem with set /A

Posted: 05 Jan 2012 11:53
by tmboredi
done! sorry i'm new at this, you guys are great :)