files count in a directory

March 24, 2009 at 07:40:12
Specs: Windows 2000
Could any body please help me on this......

I have to search count of files in a folder C:\Log\Staging

I am using the below command in my batch file :
for /F %%j in (`dir /A-D-H C:\Log\Staging^ | find /C /V "::"') do set Count=%%j

but it is throwing an error as :
| was unexpected at this time

My complete bat file looks like :

C:
CD Oracle\bin

SET COUNT = 0

for /F %%j in (`dir /A-D-H C:\Log\Staging^ | find /C /V "::"') do set Count=%%j

IF (%count% != 1) echo successful


please kindly anyone help me on this.I am very new to this one and couldnot able to resolve this issue from past few days.

Appreciate your help in advance!!!



See More: files count in a directory

Report •


#1
March 24, 2009 at 07:54:14
@DIR /A-H-D "C:\Log\Staging" >NUL 2>&1
@IF NOT ERRORLEVEL 1 ECHO successful


Report •

#2
March 24, 2009 at 21:04:58
@echo off & setLocal EnableDelayedExpansion

pushd c:\files
set N=

for /f "tokens=* delims= " %%a in ('dir/b/a-d') do (
set /a N+=1
)
echo !N! files


=====================================
If at first you don't succeed, you're about average.

M2


Report •

Related Solutions


Ask Question