Solved want to use for loop OR if else condition instead of findstr

March 9, 2018 at 06:50:03
Specs: Windows 7
@echo off & setLocal enableDELAYedeXpansioN
for /L %%a in (0 1 10) do (
for /L %%b in (1 1 10) do (
set X=%%a%%b
echo. !X!
)) >>newfile.txt

:::::::::::::::::Here is the OUTPUIT of above code:::::::::::::
11
12
13
.
.
.
98
99
::::::::::::::::generate many values in text according to the for loop::::::::::

Hello dear, please note here problem is that i do not want to see same duplicate numbers or few values like (11,22,33....), in text file, due to this we can put findstr to find out and filter it in 2nd new text file, my concern is that is it possible we can do this by using for loop?
I mean that echo. !X! is displaying results i want to add !X! in another for loop which checks !X! , if it contains 11 or 22 or 55 ... so just skip it and proceed further echo. remaining values in text file.


See More: want to use for loop OR if else condition instead of findstr

Report •

#1
March 9, 2018 at 07:55:25
@echo off&setLocal enableDELAYedeXpansioN
for /L %%a in (0,1,10) do (
for /L %%A in (1,1,10) do (
if not %%a==%%A echo %%a%%A>>newfile.txt
))
exit/b

for /L %%A in (1,1,10)
(start,step,end)
%%A can be %%a, %%A or %%0, to make them not interfere use different ones

i5-6600K[delid]@4.8GHz/4.5GHz cache@1.385v | 2x4GB Crucial-DDR4-2133@14-14-14-28 1T 2808MHz@1.37v
ASUS Z170K
Samsung 250GB SSD 850 EVO
MSI Armor RX 570 4GB@1380c/2050m BiosMod
VS450

message edited by hidde663


Report •

#2
March 13, 2018 at 00:00:38
sounds like homework, but I'll throw in:
set /a test=value %% 11
if %test% neq 0 echo %value%

Report •

#3
March 14, 2018 at 05:00:59
✔ Best Answer
damnit, forgot batch has a modulus function,

look at this fizzbuzz, made the modulus function myself >.<
for /l %%a in (1 1 100) do (set/a F=%%a-%%a/3*3&set/a B=%%a-%%a/5*5&if !F!==0 (if !B!==0 (echo FizzBuzz) else (echo Fizz)) else (if !B!==0 (echo Buzz) else echo %%a))

i5-6600K[delid]@4.814GHz/4.613GHz cache@1.385v | 2x4GB Crucial-DDR4-2133@14-14-14-28 1T 2808MHz@1.35v
ASUS Z170K
Samsung 250GB SSD 850 EVO
MSI Armor RX 570 4GB@1375c/1910m BiosMod
VS450


Report •
Related Solutions


Ask Question