Computer Hope
Microsoft => Microsoft DOS => Topic started by: drec on March 29, 2016, 08:10:50 AM
-
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 advance
-
Pipe 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.
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.
(find . -type f -mtime +30 dir "dir\")