Count files in folder

October 8, 2010 at 07:06:24
Specs: Windows XP, Core2Duo/2GB
Hello everybody,

I am making use of the below script, in order to check a specific folder for files.
If no of files is >= 1 , another .bat is to be called, (and must run as many times as the number of files in this folder) ... after that:
If no of files is 0 (zero), the execution of the actual .bat should be sttoped.

@echo on & setLocal EnableDELAYedeXpansion

dir /b /a-d dir_1>files_to_load.txt
move files_to_load.txt dir_2
set count=0
for /f %%a in (dir_2\files_to_load.txt) do ( set /a count+=1)
if %count% EQU 0 (
echo No files found in the specified folder>>FolderCounter.log
) else (
for /L %%b in (1 1 %count%) do call dir_3\MainBat.bat %%b
echo U ngarkuan !count! skedar gjithsej>> dir_2\files_to_load.txt
move FolderCounter.log dir_2

Well, I tested the above, but it doesn't stop when all files in the folder are procesed.

any ideas?

thank you all

Actually I just need a .bat to check if there are any files in the folder:
If yes ... than call the other.bat
If no ... than exit

See More: Count files in folder

Report •

October 8, 2010 at 09:16:54
@echo off & setLocal EnableDELAYedeXpansion

pushd d:\mystuff

for /f "tokens=* delims= " %%a in ('dir/b/a-d') do ( theother.bat %%a

Helping others achieve escape felicity


Report •
Related Solutions

Ask Question