1.

Solve : Hi all - trying to count files in a folder and pass it to a var can you help?

Answer»

hi the following counts all the files in a given folder and passes the value to a log file

ECHO off
SET Count=0
FOR %%A IN (dir\*.*) DO SET /A Count += 1
echo on
ECHO.%Count%>> %srclog%

but what i want to do is do the same but with files up to 30 days old can you help TRIED the following and getting wierd results -

SET cnt=0
for /f %%A in ('dir /a-d-s-h /b ^| find /V /c /d +30 ""') do set /A cnt=%%A
echo.%cnt%>> %srclog%

SET cnt2=0
for %%A in (find . -type f -mtime +30 dir "dir\") do set /A cnt2 += 1
echo.%cnt2%>> %srclog%
SET cnt2=0

SET cnt3=0
for %%A in (forfiles /P "dir" /D +30) do set /A cnt3 += 1
echo.%cnt3%>> %srclog%
SET cnt3=0


thanks in advancePipe the output of robocopy through find, with the /L switch to only list what would be copied.

Robocopy can filter by days. Don't change anything - just run it in the folder you need to count.

Code: [Select]robocopy . c:\magic /maxage:30 /fp /ndl /njh /njs /xx /L |find /c ":">> %srclog%
This portion of yours looks like a Linux command using the find on there, and not Windows.
Code: [Select](find . -type f -mtime +30 dir "dir\")



Discussion

No Comment Found