| 1. |
Solve : Count on file name? |
|
Answer» Hi rem there's numerous basic DOS routines above this line I am THINKING that I need something where I have put the blank remark line to perform the action that I want. TabCount holds the number of files with a tab extension, so you would do something like If TabCount NEQ 1 GoTo ErrorLabel Rem else continue, only 1 present GrahamThanks Graham. Almost got it I think. Scratching my head over these following SCENARIO though:- Quote dir /b *.tab | find /c /i ".tab"> $test$ Ok these commands result in the variable having a value of 1 (I have checked using Set) But with the following code:- Quote If TabCount EQU 1 Goto OneReturned The result is always NEQ 1 - have I MISSED something? Thanks Whoops, my fault I forgot to wrap the TabCount in % symbols It should have read : If %TabCount% EQU 1 Goto OneReturned If %TabCount% NEQ 1 Goto TooMany If you really want to test that the condition, try this REM test line below Set TabCount=2 If %TabCount% EQU 1 Goto OneReturned If %TabCount% NEQ 1 Goto TooMany GrahamSpot on! Edit: ANYBODY reading this and wanting to use similar syntax, it is worth checking the name of your variable - as the set up above requires checking the condition against %TabCount % and not %TabCount%. To check this, once you have done this bit:- Quote dir /b *.tab | find /c /i ".tab"> $test$ Issue a Set command to see how the variable is held. Mine came out as TabCount =1 Therefore when I issued the If %TabCount% EQU 1 go do something - it ignored the line as the condition was not met. Changing to If %TabCount % EQU 1 go do something worked. ANyway, thanks for the solution Graham! |
|