DOS batch file

Hewlett-packard Compaq presario cq5320f...
April 8, 2010 at 16:55:08
Specs: Windows XP, 1 gb
Hi,

I am doing some project in batch file and stuck. I need to run a batch file when file count is 10.

By the help of the below mentioned command I could get the number of files in the directory but clue less how can i run the other batch file when the file count reaches to a specific number.

dir /b/s "c:\test3" |find /c /v ""

My problem is
if (dir /b/s "c:\test3" |find /c /v "")=10 then I need to run sam.bat

Any help is highly appreciated.


See More: DOS batch file

Report •

#1
April 8, 2010 at 17:48:16
very hard to do in dos-native batchscript, as i'm sure you are aware of. Your intro shows you running winXP. If that is the case, it's a breeze, if not, it's prob'ly impossible using dos-batch alone. In old dos, "FIND" does not even set the errorlevel > 0 when string not found.
If you're running winXP, post to programming forum instead of dos, you'll get help by tomorrow at latest.
here's my XP stab:
for /f %%a in ('dir /b/s "c:\test3" ^|find /c /v "") set xx=%%a
if %xx% equ 10 call sam
::------ end
ps: substitute "if gte" for greater-or-equal, etc.

Report •

#2
April 9, 2010 at 06:23:24
Hi,
Thanks for your reply,

I am getting an error message. "set was unexpected at this time"

Can you please help


Report •

#3
April 9, 2010 at 08:19:15
If it's DOS, forget it. Id it's XP:

======================
@echo off & setLocal EnableDELAYedeXpansion

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


=====================================
Helping others achieve escape felicity

M2


Report •

Related Solutions

#4
June 7, 2010 at 04:07:32
"If it's DOS, forget it." This isn't true. Actually it can be done under DOS!

It just takes some additional tools known as batch enhancers. There are quite a number of them around, try to google for them or simply look here http://www.bttr-software.de/products/jhoffmann/ for a zip archive named DOSUTILS.ZIP. Should you need more information, please let me know.


Report •

Ask Question