Why doesn't my IF work - batch-file

I have this problem with my IF query.
IF "!ProzentS_[%Temp_Counter2%]!"LSS"%MIN_THRESHOLD%" (
set WARTUNG_[%Temp_Counter2%]=true
ECHO XXXXXXXXXX %DATE:~-4%%DATE:~-7,2%%DATE:~-10,2%_%Time% TEST !WARTUNG_[%Temp_Counter2%]! !BAT_[%Temp_Counter2%]! >> %PATH_LOGDATEI%\%LOGFILE_NAME%
)
Somehow it has a problem with the brackets
"(" can not be processed syntactically at this point
if I use "LSS" "EQU" or "GTR" it does not count them but if i put "==" there it works.
IF "!ProzentS_[%Temp_Counter2%]!"=="%MIN_THRESHOLD%" (
)
Can someone tell me why this happens.

you need more space:
IF "!ProzentS_[%Temp_Counter2%]!" LSS "%MIN_THRESHOLD%" (
set WARTUNG_[%Temp_Counter2%]=true
ECHO XXXXXXXXXX %DATE:~-4%%DATE:~-7,2%%DATE:~-10,2%_%Time% TEST !WARTUNG_[%Temp_Counter2%]! !BAT_[%Temp_Counter2%]! >> %PATH_LOGDATEI%\%LOGFILE_NAME%
)

Related

Batch file crashes when using list with 10,000 items

I'm making a batch file that is supposed to run through roughly 10,000 numbers.
I created a program to make a list and echo items from the list one at a time with a for loop. When I inputted my 10,000 numbers for the list the batch file only crashes. Am I past the size limit for lists in batch files or did I mess up the syntax somewhere? Thanks in advance.
#echo off
setlocal
set "list=300086899 300086975 300086991 300086997 300087012 300087015 300087019 300087020 300087027 300087033 300087034 300087035 300087036 300087037 300087038 300087039 300087040 300087041 300087042 300087043 300087061 300087073 300087079 300087082 300087160 300087168 300087416 300087500 300087501 300087504 300087508 300087509 300087513 300087518 300087521 300087525 300087595 300087598 300087622 300087627 300087629 300087635 300087636 300087638 300087641 300087645 300087648 300087651 300087652 300087653 300087654 300087814 300087826 300087836 300087868 300087873 300087879 300087883 300087893 300087894 300087947 300087952 300087961 300087963 300087966 300087968 300087969 300087975 300087982 300088001 300088003 300088005 300088008 300088012 300088018 300088023 300088026 300088027 300088041 300088042 300088043 300088044 300088046 300088063 300088064 300088065 300088067 300088068 300088071 300088074 300088077 300088079 300088102 300088124 300088129 300088131 300088135 300088138 300088142 300088146 300088151 300088156 300088159 300088161 300088163 300088169 300088171 300088173 300088174 300088176 300088180 300088183 300088186 300088342 300088349 300088350 300088355 300088358 300088364 300088367 300088374 300088382 300088392 300088406 300088409 300088412 300088415 300088418 300088425 300088432 300088439 300088446 300088449 300088453 300088458 300088460 300088461 300088465 300088466 300088469 300088470 300088471 300088478 300088481 300088482 300088563 300088565 300088567 300088569 300088572 300088574 300088575 300088576 300088577 300088578 300088579 300088582 300088585 300088586 300088590 300088622 300088624 300088999 300089006 300089012 300089018 300089020 300089023 300089027 300089034 300089048 300089059 300089061 300089062 300089068 300089069 300089071 300089073 300089075 300089082 300089083 300089164 300089168 300089170 300089176 300089179 300089181 300089182 300089188 300089190 300089448 300089466 300089473 300089481 300089502 300089567 300089573 300089577 300089582 300089685 300089696 300089707 300089715 300089717 300089719 300089723 300089733 300089736 300089738 300089740 300089742 300090152 300090174 300090178 300090183 300090187 300090189 300090191 300090194 300090195 300090197 300090198 300090205 300090207 300090208 300090209 300090219 300090222 300090226 300090229 300090248 300090251 300090317 300090324 300090327 300090341 300090345 300090712 300090719 300090725 300090737 300090744 300090745 300090748 300090750 300090752 300090754 300090757 300090765 300090773 300090779 300090786 300090790 300090791 300090795 300090798 300090801 300090803 300090806 300090807 300090808 300090811 300090812 300090815 300090816 300090817 300090818 300090819 300090822 300090824 300090828 300090832 300090836 300090839 300090840 300090844 300090852 300090856 300090860 300090865 300090866 300090869 300090871 300090881 300090906 300090921 300090924 300090927 300090932 300090934 300090939 300090944 300090948 300090950 300090956 300090957 300090958 300090959 300090960 300090961 300090962 300090964 300090965 300090967 300090970 300090973 300090975 300090976 300090977 300090978 300090979 300090980 300090984 300090985 300090986 300090987 300090988 300090989 300090990 300090991 300090992 300090993 300090994 300090995 300090996 300091146 300091148 300091153 300091157 300091159 300091181 300091209 300091212 300091232 300091239 300091258 300091261 300091267 300091277 300091285 300091291 300091297 300091312 300091319 300091329 300091368 300091387 300091417 300091421 300091424 300091445 300091493 300091496 300091500 300091502 300091566 300091571 300091573 300091574 300091575 300091576 300091586 300091843 300091847 300091908 300091909 300091912 300091915 300091922 300091933 300091959 300091960 300091969 300092018 300092033 300092034 300092036 300092051 300092067 300092074 300092077 300092083 300092085 300092086 300092104 300092109 300092159 300092160 300092161 300092163 300092164 300092320 300092321 300092323 300092326 300092330 300092331 300092332 300092336 300092338 300092362 300092367 300092368 300092372 300092374 300092377 300092424 300092467 300092508 300092512 300092530 300092534 300092535 300092538 300092630 300092634 300092653 300092657 300092661 300092670 300092671 300092673 300092676 300092682 300092685 300092690 300092691 300092696 300092952 300092959 300092963 300092987 300093045 300093057 300093063 300093067 300093079 300093095 300093107 300093122 300093124 300093138 300093141 300093144 300093146 300093151 300093155 300093157 300093159 300093162 300093166 300093176 300093180 300093235 300093239 300093241 300093242 300093244 300093246 300093247 300093250 300093252 300093253 300093255 300093257 300093259 300093261 300093262 300093268 300093281 300093295 300093311 300093320 300093322 300093324 300093328 300093331 300093333 300093337 300093338 300093340 300093341 300093343 300093344 300093346 300093348 300093349 300093350 300093351 300093353 300093354 300093356 300093358 300093359 300093361 300093362 300093363 300093365 300093377 300093661 300093691 300093697 300093703 300093705 300093726 300093740 300093747 300093756 300093759 300093768 300093900 300093902 300093903 300094055 300094067 300094297 300094319 300094345 300094353 300094368 300094390 300094407 300094436 300094443 300094445 300094448 300094508 300094512 300094514 300094555 300094556 300094598 300094637 300094949 300094964 300094969 300094994 300094995 300095021 300095029 300095031 300095032 300095034 300095041 300095042 300095043 300095046 300095048 300095063 300095064 300095065 300095328 300095337 300095344 300095346 300095359 300095368 300095432 300095482 300095833 300095848 300095852 300095981 300095984 300096004 300096015 300096019 300096020 300096054 300096055 300096057 300096063 300096066 300096376 300096388 300096417 300096676 300096753 300096771 300096776 300096835 300096837 300096857 300096864 300096867 300096874 300096878 300096884 300096910 300096911 300096912 300096919 300096981 300096982 300096985 300096986 300096989 300096991 300096995 300097320 300097326 300097330 300097380 300097387 300097391 300097400 300097412 300097433 300097442 300097458 300097482 300097486 300097488 300097490 300097491 300097492 300097493 300097494 300097495 300097496 300097497 300097498 300097499 300097500 300097501 300097502 300098154 300098165 300098286 300098288 300098314 300098320 300098385 300098461 300098500 300098936 300098938 300098940 300098946 300098949 300098950 300098974 300098994 300099000 300099008 300099009 300099125 300099369 300099395 300099431 300099434 300099497 300099542 300099547 300099551 300099552 300099564 300099664 300099667 300100257 300100367 300100388 300100419 300100481 300100869 300100885 300100889 300100918 300101435 300101449 300101453 300101515 300101526 300101528 300101531 300101550 300101574 300101580 300102002 300102004 300102007 300102011 300102031 300102034 300102039 300102043 300102045 300102494 300102496 300102509 300102532 300102863 300102915 300103110 300104074 300104299 300105704 300105708 300105714 300105719 300106819 300106821 300106823 300106824 300106825 300106828 300106829 300106830 300106831 300106832 300106833 300106834 300106835 300106836 300106837 300106838 300106839 300106840 300106841 300106842 300106846 300106848 300106850 300106851 300106852 300106853 300106854 300106855 300106856 300106858 300106859 300106860 300106861 300106862 300106863 300106864 300106865 300106866 300106867 300106868 300106869 300106870 300106871 300106872 300106873 300106874 300106875 300106876 300107099 300107111 300107115 300107120 300107129 300107134 300107138 300107259 300107292 300107293 300107294 300107295 300107296 300107299 300107308 300107310 300107312 300107313 300107314 300107315 300107323 300107324 300107326 300107327 300107328 300107329 300107338 300107362 300107368 300107372 300107373 300107374 300107375 300107376 300107377 300107378 300107379 300107482 300107484 300107486 300107489 300107492 300107495 300107496 300107498 300107500 300107502 300107503 300107504 300107505 300107508 300107510 300107512 300107514 300107516 300107517 300107518 300107522 300107526 300107529 300107540 300107546 300107556 300107558 300107562 300107564 300107571 300107575 300107578 300107582 300107586 300107589 300107591 300107593 300107597 300107598 300107604 300107606 300107608 300107610 300107611 300107613 300107616 300107618 300107622 300107623 300107624 300107625 300107626 300107627 300107628 300107629 300107630 300107631 300107633 300107634 300107635 300107636 300107639 300107640 300107641 300107642 300107643 300107644 300107645 300107646 300107647 300107648 300107649 300107651 300107652 300107655 300107656 300107661 300107662 300107663 300107679 300107688 300107880 300107884 300107891 300107965 300107971 300107980 300107982 300107987 300108027 300108030 300108031 300108294 300108296 300108298 300108302 300108308 300108314 300108317 300108325 300108327 300108329 300108332 300108335 300108338 300108341 300108342 300108344 300108345 300108347 300108349 300108352 300108353 300108355 300108357 300108358 300108361 300108364 300108368 300108372 300108386 300108436 300108437 300108440 300108441 300108449 300108455 300108458 300108464 300108495 300108497 300108498 300108499 300108682 300108685 300108702 300108703 300108709 300108710 300108787 300108788 300108789 300108790 300108791 300109049 300109057 300109061 300109131 300109165 300109180 300109181 300109182 300109183 300109184 300109218 300109219 300109220 300109533 300109633 300109634 300109635 300109636 300109637 300109638 300109642 300109643 300109644 300109646 300109647 300109648 300109657 300109665 300109666 300109667 300110023 300110042 300110043 300110046 300110070 300110073 300110074 300110075 300110076 300110080 300110083 300110084 300110087 300110088 300110089 300110090 300110091 300110092 300110098 300110106 300110107 300110108 300110109 300110116 300110118 300110119 300110308 300110320 300110328 300110332 300110334 300110338 300110340 300110343 300110346 300110347 300110357 300110364 300110370 300110376 300110379 300110382 300110399 300110400 300110428 300110429 300110430 300110431 300110434 300110435 300110436 300110438 300110439 300110440 300110441 300110442 300110444 300110446 300110447 300110449 300110450 300110452 300110454 300110512 300110517 300110518 300110740 300110742 300110744 300110749 300110750 300110751 300110758 300110761 300110766 300110771 300110785 300110789 300110883 300110886 300110888 300110890 300110892 300110893 300110895 300110896 300110897 300110904 300110906 300110907 300110924 300110925 300110926 300110927 300110928 300110932 300110935 300110936 300110937 300110938 300110939 300110940 300110942 300110944 300110945 300110946 300110947 300110948 300110949 300110950 300110954 300110955 300110958 300110961 300110962 300110963 300110964 300111141 300111147 300111177 300111186 300111188 300111189 300111190 300111191 300111194 300111195 300111198 300111200 300111205 300111209 300111210 300111211 300111212 300111215 300111217 300111219 300111220 300111223 300111225 300111226 300111230 300111233 300111234 300111235 300111236 300111237 300111238 300111239 300111241 300111242 300111243 300111244 300111245 300111246 300111247 300111248 300111249 300111254 300111256 300111565 300111566 300111570 300111571 300111577 300111588 300111589 300111591 300111595 300111597 300111602 300111609 300111614 300111617 300111619 300111624 300111626 300111628 300111631 300111633 300111635 300111638 300111644 300111646 300111647 300111663 300111664 300111665 300111667 300111668 300111669 300111670 300111671 300111672 300111673 300111674 300111675 300111676 300111677 300111678 300111679 300111680 300111681 300111682 300111683 300111684 300111685 300111686 300111687 300111688 300111689 300111690 300111693 300111694 300111695 300111696 300111821 300111823 300111885 300111886 300111887 300111888 300111889 300111890 300111892 300111893 300111894 300112145 300112149 300112152 300112155 300112157 300112164 300112166 300112190 300112191 300112193 300112194 300112195 300112196 300112197 300112198 300112199 300112200 300112201 300112202 300112203 300112205 300112206 300112209 300112514 300112564 300112566 300112568 300112569 300112572 300112573 300112574 300112575 300112577 300112581 300112583 300112584 300112585 300112586 300112590 300112592 300112593 300112594 300112595 300112596 300112597 300112598 300112599 300112600 300112601 300112602 300112606 300112608 300112647 300112951 300112954 300112957 300112971 300112974 300112977 300112980 300113003 300113006 300113013 300113027 300113030 300113031 300113035 300113064 300113067 300113134 300113168 300113171 300113175 300113177 300113184 300113187 300113189 300113196 300113199 300113201 300113245 300113251 300113262 300113263 300113265 300113266 300113270 300113273 300113276 300113278 300113465 300113469 300113471 300113475 300113476 300113482 300113487 300113490 300113492 300113495 300113499 300113505 300113516 300113535 300113605 300113606 300113622 300113623 300113629 300113633 300113634 300113636 300113637 300113638 300113642 300113656 300113661 300113668 300113669 300113677 300113683 300113689 300113691 300113896 300113901 300113903 300113906 300113908 300113910 300113915 300113916 300113943 300113945 300113955 300113957 300113958 300113960 300113961 300113963 300113964 300113965 300113988 300113990 300113991 300113994 300114133 300114134 300114135 300114136 300114137 300114140 300114142 300114143 300114144 300114147 300114148 300114149 300114150 300114151 300114153 300114157 300114159 300114162 300114167 300114174 300114176 300114177 300114178 300114218 300114220 300114223 300114224 300114225 300114255 300114258 300114260 300114261 300114264 300114266 300114268 300114272 300114274 300114275 300114276 300114283 300114286 300114287 300114290 300114292 300114293 300114294 300114295 300114296 300114298 300114299 300114300 300114301 300114304 300114305 300114307 300114312 300114315 300114316 300114511 300114524 300114621 300114623 300114624 300114626 300114627 300114633 300114636 300114638 300114651 300114654 300114656 300114658 300114659 300114661 300114665 300114666 300114667 300114674 300114679 300114683 300114686 300114689 300114690 300114691 300114692 300114694 300114695 300114698 300114699 300114700 300114701 300114703 300114708 300114717 300114722 300114724 300114725 300114727 300114896 300114902 300114915 300114916 300114919 300114931 300114932 300114934 300114936 300114937 300114938 300114940 300114941 300114944 300114949 300114950 300115012 300115039 300115041 300115043 300115045 300115047 300115048 300115049 300115051 300115053 300115071 300115072 300115073 300115074 300115078 300115394 300115395 300115396 300115402 300115406 300115409 300115413 300115416 300115424 300115427 300115437 300115464 300115472 300115473 300115474 300115481 300115482 300115483 300115484 300115485 300115493 300115494 300115495 300115497 300115498 300115499 300115500 300115501 300115502 300115504 300115505 300115508 300115509 300115510 300115518 300115520 300115522 300115523 300115533 300115535 300115536 300115537 300115538 300115540 300115552 300115553 300115577 300115717 300115724 300115725 300115776 300115821 300115825 300115827 300115829 300115831 300115832 300115833 300115835 300115846 300115849 300115870 300115873 300115890 300115910 300115912 300115914 300115918 300115920 300115922 300115923 300115925 300115930 300115937 300115953 300115954 300115969 300115994 300116236 300116240 300116307 300116308 300116314 300116315 300116338 300116340 300116341 300116351 300116352 300116353 300116354 300116356 300116359 300116360 300116364 300116367 300116369 300116370 300116375 300116376 300116582 300116583 300116585 300116589 300116593 300116595 300116598 300116602 300116613 300116614 300116615 300116618 300116620 300116623 300116624 300116625 300116626 300116628 300116631 300116634 300116654 300116660 300116672 300116674 300116690 300116692 300116694 300116695 300116696 300116697 300116699 300116700 300116701 300116702 300116703 300116704 300116705 300116706 300116707 300116708 300116710 300116711 300116712 300116713 300116714 300116716 300116717 300116718 300116719 300116720 300116721 300116722 300116723 300116724 300116725 300116727 300116728 300116729 300116730 300116731 300116734 300116895 300116906 300116933 300116941 300116944 300116948 300116957 300116964 300116966 300116970 300116972 300116976 300116989 300116991 300117007 300117012 300117013 300117015 300117024 300117034 300117035 300117037 300117039 300117040 300117041 300117044 300117045 300117059 300117060 300117061 300117064 300117068 300117071 300117077 300117080 300117082 300117085 300117087 300117089 300117094 300117095 300117098 300117100 300117101 300117102 300117104 300117106 300117110 300117112 300117113 300117117 300117121 300117137 300117143 300117168 300117172 300117508 300117509 300117510 300117512 300117513 300117515 300117520 300117521 300117523 300117525 300117529 300117543 300117552 300117565 300117570 300117578 300117581 300117582 300117583 300117584 300117586 300117587 300117588 300117589 300117593 300117596 300117598 300117603 300117604 300117605 300117606 300117607 300117608 300117610 300117611 300117612 300117613 300117614 300117615 300117629 300117867 300117930 300117957 300117977 300117982 300117986 300117994 300117999 300118003 300118006 300118009 300118010 300118019 300118023 300118033 300118036 300118037 300118042 300118043 300118044 300118045 300118046 300118057 300118062 300118064 300118065 300118066 300118255 300118257 300118260 300118267 300118268 300118281 300118293 300118299 300118308 300118316 300118328 300118332 300118343 300118349 300118359 300118364 300118376 300118380 300118382 300118385 300118387 300118389 300118390 300118394 300118398 300118400 300118404 300118408 300118410 300118413 300118415 300118417 300118419 300118420 300118422 300118424 300118435 300118437 300118439 300118440 300118441 300118442 300118443 300118444 300118445 300118446 300118447 300118448 300118449 300118450 300118451 300118453 300118454 300118455 300118456 300118457 300118458 300118459 300118460 300118461 300118462 300118463 300118464 300118465 300118466 300118469 300118470 300118475 300118478 300118479 300118485 300118486 300118491 300118493 300118496 300118498 300118499 300118504 300118506 300118507 300118509 300118510 300118511 300118512 300118513 300118514 300118515 300118516 300118713 300118718 300118722 300118727 300118729 300118731 300118753 300118758 300118763 300118766 300118769 300118773 300118780 300118781 300118784 300118789 300118792 300118795 300118800 300118803 300118811 300118814 300118819 300118827 300118828 300118830 300118831 300118832 300118833 300118835 300118839 300118840 300118841 300118843 300118845 300118846 300118847 300118864 300118866 300118883 300118887 300118911 300118913 300118914 300118915 300118919 300118922 300118929 300118931 300118942 300118947 300118962 300118963 300118964 300118966 300118968 300118982 300118983 300118985 300118986 300118987 300118990 300119124 300119131 300119133 300119137 300119193 300119197 300119198 300119204 300119207 300119213 300119214 300119215 300119217 300119218 300119219 300119222 300119223 300119224 300119227 300119228 300119229 300119230 300119231 300119232 300119233 300119234 300119237 300119248 300119249 300119250 300119253 300119254 300119255 300119258 300119260 300119261 300119262 300119396 300119399 300119402 300119430 300119435 300119437 300119439 300119441 300119455 300119460 300119461 300119462 300119463 300119464 300119465 300119470 300119472 300119473 300119475 300119477 300119479 300119485 300119495 300119503 300119505 300119506 300119510 300119513 300119521 300119523 300119527 300119540 300119542 300119548 300119550 300119553 300119554 300119556 300119558 300119560 300119564 300119565 300119567 300119579 300119592 300119625 300119780 300119814 300119819 300119825 300120006 300120026 300120029 300120038 300120044 300120110 300120112 300120117 300120122 300120298 300120312 300120314 300120397 300120402 300120404 300120414 300120421 300120479 300120481 300120501 300120507 300120556 300120804 300120820 300120912 300120934 300120937 300120939 300120942 300120948 300120950 300120953 300120994 300121000 300121008 300121035 300121036 300121037 300121041 300121042 300121043 300121044 300121045 300121046 300121047 300121048 300121049 300121050 300121172 300121178 300121183 300121186 300121188 300121213 300121221 300121232 300121235 300121265 300121267 300121270 300121273 300121276 300121278 300121287 300121290 300121291 300121292 300121293 300121294 300121295 300121296 300121302 300121312 300121316 300121323 300121327 300121332 300121333 300121334 300121335 300121336 300121337 300121338 300121346 300121348 300121352 300121354 300121355 300121358 300121360 300121362 300121363 300121367 300121374 300121377 300121385 300121437 300121751 300121766 300121769 300121770 300121771 300121772 300121773 300121774 300121775 300121776 300121777 300121778 300121779 300121780 300121781 300121782 300121783 300121784 300121785 300121787 300121791 300121792 300121796 300121798 300121799 300121801 300121804 300121812 300121815 300121819 300121821 300121823 300121825 300121826 300121841 300121842 300121847 300121850 300121853 300121855 300121856 300121857 300121858 300121860 300121862 300121863 300121864 300121866 300121870 300121872 300121874 300122025 300122035 300122043 300122052 300122055 300122057 300122077 300122091 300122098 300122108 300122110 300122111 300122113 300122114 300122115 300122119 300122122 300122124 300122125 300122128 300122146 300122155 300122157 300122159 300122162 300122165 300122166 300122190 300122193 300122194 300122201 300122205 300122223 300122228 300122235 300122236 300122237 300122240 300122241 300122242 300122243 300122244 300122246 300122247 300122254 300122349 300122357 300122360 300122363 300122364 300122367 300122369 300122372 300122419 300122448 300122464 300122465 300122471 300122474 300122475 300122481 300122483 300122484 300122490 300122496 300122498 300122508 300122643 300122668 300122670 300122672 300122674 300122680 300122683 300122686 300122689 300122694 300122699 300122701 300122704 300122709 300122712 300122713 300122714 300122715 300122716 300122717 300122719 300122720 300122721 300122725 300122727 300122729 300122731 300122733 300122736 300122737 300122740 300122741 300122743 300122744 300122746 300122747 300122749 300122750 300122751 300122758 300122759 300122760 300122761 300122762 300122763 300122764 300122773 300122775 300122776 300122778 300122780 300122782 300122784 300122785 300122788 300122790 300122791 300122794 300122795 300122796 300122798 300122805 300122808 300122809 300122812 300122813 300122814 300122815 300122816 300122817 300122827 300122831 300122846 300122861 300122863 300122872 300122873 300122874 300122879 300123152 300123157 300123164 300123166 300123171 300123174 300123180 300123188 300123191 300123192 300123193 300123195 300123210 300123221 300123226 300123228 300123229 300123233 300123234 300123236 300123238 300123246 300123318 300123320 300123333 300123334 300123338 300123340 300123343 300123344 300123349 300123350 300123351 300123352 300123353 300123372 300123556 300123574 300123589 300123590 300123608 300123610 300123615 300123617 300123619 300123621 300123624 300123651 300123653 300123664 300123665 300123667 300123669 300123672 300123686 300123687 300123696 300123720 300123725 300123731 300123732 300123735 300123746 300123763 300123766 300123768 300123869 300123871 300123873 300123888 300123894 300123914 300123926 300123928 300123939 300123947 300123952 300123956 300123970 300123973 300123976 300123977 300123980 300123985 300123986 300123987 300123988 300123990 300123991 300123992 300123993 300123994 300123995 300124001 300124010 300124011 300124012 300124013 300124014 300124015 300124017 300124021 300124024 300124027 300124033 300124036 300124040 300124044 300124046 300124048 300124052 300124053 300124232 300124234 300124295 300124297 300124301 300124320 300124348 300124349 300124370 300124374 300124390 300124392 300124394 300124395 300124396 300124398 300124399 300124400 300124401 300124402 300124420 300124421 300124434 300124435 300124436 300124437 300124642 300124667 300124671 300124685 300124686 300124689 300124694 300124700 300124706 300124774 300124779 300124781 300124783 300124787 300124788 300124790 300124791 300124792 300124802 300124803 300124820 300124827 300124828 300124829 300124830 300124831 300124832 300124836 300124842 300124843 300124844 300124845 300124846 300124847 300124848 300124849 300124850 300124851 300124852 300124853 300124854 300124855 300124856 300124862 300124863 300124865 300124867 300124869 300124871 300124872 300124873 300124874 300124875 300124876 300124877 300124878 300124879 300124880 300124881 300124882 300124883 300124885 300124886 300124888 300125017 300125044 300125069 300125087 300125091 300125096 300125097 300125104 300125107 300125108 300125111 300125113 300125120 300125125 300125148 300125151 300125154 300125160 300125169 300125178 300125179 300125183 300125192 300125223 300125224 300125226 300125227 300125229 300125231 300125232 300125234 300125236 300125258 300125260 300125261 300125262 300125280 300125282 300125284 300125291 300125308 300125310 300125311 300125319 300125323 300125327 300125348 300125351 300125355 300125357 300125358 300125359 300125371 300125372 300125377 300125378 300125405 300125406 300125408 300125409 300125411 300125413 300125414 300125632 300125645 300125662 300125665 300125668 300125678 300125686 300125697 300125703 300125705 300125723 300125733 300125736 300125763 300125776 300125800 300125802 300125806 300125818 300125820 300125821 300125822 300125823 300125824 300125828 300125831 300125833 300125836 300125838 300126133 300126158 300126164 300126168 300126175 300126185 300126193 300126196 300126197 300126200 300126204 300126205 300126206 300126207 300126210 300126216 300126221 300126222 300126223 300126224 300126225 300126226 300126227 300126229 300126230 300126231 300126232 300126233 300126234 300126235 300126238 300126239 300126240 300126242 300126243 300126247 300126248 300126249 300126250 300126256 300126257 300126265 300126268 300126419 300126423 300126436 300126466 300126467 300126469 300126473 300126482 300126487 300126490 300126491 300126580 300126581 300126586 300126589 300126592 300126594 300126595 300126596 300126597 300126598 300126599 300126600 300126603 300126606 300126609 300126613 300126618 300126706 300126707 300126712 300126713 300126714 300126715 300126718 300126719 300126720 300126721 300126722 300126723 300126927 300126929 300126931 300126935 300126937 300126941 300126945 300126949 300126954 300126958 300126961 300126965 300126966 300126971 300126975 300126977 300126980 300127033 300127044 300127046 300127053 300127055 300127070 300127071 300127072 300127073 300127098 300127111 300127297 300127302 300127307 300127322 300127328 300127330 300127334 300127337 300127340 300127347 300127349 300127354 300127359 300127362 300127397 300127399 300127400 300127401 300127403 300127421 300127462 300127465 300127466 300127470 300127479 300127482 300127485 300127488 300127489 300127490 300127491 300127492 300127495 300127762 300127765 300127769 300127772 300127775 300127778 300127781 300127793 300127799 300127805 300127811 300127812 300127813 300127817 300127823 300127826 300127828 300127833 300127837 300127839 300127841 300127845 300127846 300127851 300127854 300127857 300127858 300127860 300127862 300127864 300127865 300127867 300127894 300127895 300127901 300127916 300127917 300127918 300127919 300127920 300127921 300127927 300127928 300127929 300127930 300127931 300127933 300127934 300127935 300127936 300127943 300127945 300127946 300127947 300127948 300127949 300127950 300127951 300127952 300127953 300127954 300127955 300128204 300128206 300128210 300128214 300128219 300128222 300128225 300128227 300128230 300128234 300128238 300128245 300128252 300128256 300128260 300128262 300128267 300128270 300128273 300128275 300128278 300128280 300128282 300128285 300128286 300128288 300128291 300128302 300128305 300128316 300128318 300128322 300128324 300128325 300128326 300128333 300128336 300128337 300128338 300128339 300128340 300128341 300128342 300128343 300128344 300128345 300128346 300128347 300128348 300128351 300128352 300128353 300128354 300128355 300128356 300128357 300128358 300128359 300128360 300128537 300128538 300128556 300128588 300128589 300128604 300128607 300128610 300128611 300128614 300128618 300128620 300128621 300128627 300128629 300128630 300128631 300128635 300128636 300128637 300128638 300128640 300128641 300128643 300128644 300128645 300128648 300128654 300128655 300128656 300128657 300128658 300128659 300128823 300128827 300128834 300128837 300128851 300128853 300128854 300128856 300128864 300128872 300128877 300128886 300128890 300128893 300128894 300128896 300128898 300128901 300128902 300128904 300128905 300128906 300128908 300128909 300128910 300128911"
(
for %%i in (%list%) do (
echo(%%i
echo(
pause
)
If you list the reason and the concept behind your number list, there might be another solution, but for now, create a text file numbers.txt:
300086899
300086975
300086991
300086997
300087012
300087015
...
Then, the batch file:
#for /f %%i in (numbers.txt) do (
#echo %%i
#echo(
)

vbscript to select file and save directory?

I'm currently working on a program that can start other Programs. Its in batch. But i need it to be user friendly. I want a code that can open a file select window, and save the directory of what i selected into a txt file (or csv or whatever). I'm new on VBS so forgive me if I'm missing something simple. But i searched for a while and got close, only to fail.
Here's what i have so far...
Set shell = CreateObject( "WScript.Shell" )
defaultLocalDir = shell.ExpandEnvironmentStrings("%USERPROFILE%") & "\Desktop"
Set shell = Nothing
file = ChooseFile(defaultLocalDir)
wscript.echo file
Function ChooseFile (ByVal initialDir)
Set objWMIService = GetObject("winmgmts:\\.\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * from Win32_OperatingSystem")
Dim winVersion
' This collection should contain just the one item
For Each objItem in colItems
'Caption e.g. Microsoft Windows 7 Professional
'Name e.g. Microsoft Windows 7 Professional |C:\windows|...
'OSType e.g. 18 / OSArchitecture e.g 64-bit
'Version e.g 6.1.7601 / BuildNumber e.g 7601
winVersion = CInt(Left(objItem.version, 1))
Next
Set objWMIService = Nothing
Set colItems = Nothing
If (winVersion <= 5) Then
' Then we are running XP and can use the original mechanism
Set cd = CreateObject("UserAccounts.CommonDialog")
cd.InitialDir = initialDir
cd.Filter = "ZIP files|*.zip|Text Documents|*.txt|Shell Scripts|*.*sh|All Files|*.*"
' filter index 4 would show all files by default
' filter index 1 would show zip files by default
cd.FilterIndex = 1
If cd.ShowOpen = True Then
ChooseFile = cd.FileName
Else
ChooseFile = ""
End If
Set cd = Nothing
Else
' We are running Windows 7 or later
Set shell = CreateObject( "WScript.Shell" )
Set ex = shell.Exec( "mshta.exe ""about: <input type=file id=X><script>X.click();new ActiveXObject('Scripting.FileSystemObject').GetStandardStream(1).WriteLine(X.value);close();resizeTo(0,0);</script>""" )
ChooseFile = Replace( ex.StdOut.ReadAll, vbCRLF, "" )
Set ex = Nothing
Set shell = Nothing
End If
End Function
Maybe you are looking for something like next bat code snippet?
#echo OFF
SETLOCAL enableextensions
set "_chosen="
if exist "_saved.txt" (
rem read previously saved value
<"_saved.txt" set /P "_chosen="
echo read previously saved value
) else (
for /f "delims=" %%G in ('
cscript //NOLOGO "D:\VB_scripts\SO\31656148.vbs"
') do (
set "_chosen=%%G"
rem save value to a file
>"_saved.txt" echo(%%G
echo file chosen, value saved
)
)
if defined _chosen (
echo("%_chosen%"
) else (
echo no file chosen
)

Split text file into smaller multiple text file using command line

I have multiple text file with about 100,000 lines and I want to split them into smaller text files of 5000 lines each.
I used:
split -l 5000 filename.txt
That creates files:
xaa
xab
aac
xad
xbe
aaf
files with no extensions. I just want to call them something like:
file01.txt
file02.txt
file03.txt
file04.txt
or if that is not possible, i just want them to have the ".txt" extension.
I know the question was asked a long time ago, but I am surprised that nobody has given the most straightforward Unix answer:
split -l 5000 -d --additional-suffix=.txt $FileName file
-l 5000: split file into files of 5,000 lines each.
-d: numerical suffix. This will make the suffix go from 00 to 99 by default instead of aa to zz.
--additional-suffix: lets you specify the suffix, here the extension
$FileName: name of the file to be split.
file: prefix to add to the resulting files.
As always, check out man split for more details.
For Mac, the default version of split is dumbed down. You can install the GNU version using the following command. (see this question for more GNU utils)
brew install coreutils
and then you can execute the above command by replacing split with gsplit. Check out man gsplit for details.
Here's an example in C# (cause that's what I was searching for). I needed to split a 23 GB csv-file with around 175 million lines to be able to look at the files. I split it into files of one million rows each. This code did it in about 5 minutes on my machine:
var list = new List<string>();
var fileSuffix = 0;
using (var file = File.OpenRead(#"D:\Temp\file.csv"))
using (var reader = new StreamReader(file))
{
while (!reader.EndOfStream)
{
list.Add(reader.ReadLine());
if (list.Count >= 1000000)
{
File.WriteAllLines(#"D:\Temp\split" + (++fileSuffix) + ".csv", list);
list = new List<string>();
}
}
}
File.WriteAllLines(#"D:\Temp\split" + (++fileSuffix) + ".csv", list);
#ECHO OFF
SETLOCAL
SET "sourcedir=U:\sourcedir"
SET /a fcount=100
SET /a llimit=5000
SET /a lcount=%llimit%
FOR /f "usebackqdelims=" %%a IN ("%sourcedir%\q25249516.txt") DO (
CALL :select
FOR /f "tokens=1*delims==" %%b IN ('set dfile') DO IF /i "%%b"=="dfile" >>"%%c" ECHO(%%a
)
GOTO :EOF
:select
SET /a lcount+=1
IF %lcount% lss %llimit% GOTO :EOF
SET /a lcount=0
SET /a fcount+=1
SET "dfile=%sourcedir%\file%fcount:~-2%.txt"
GOTO :EOF
Here's a native windows batch that should accomplish the task.
Now I'll not say that it'll be fast (less than 2 minutes for each 5Kline output file) or that it will be immune to batch character-sensitivites. Really depends on the characteristics of your target data.
I used a file named q25249516.txt containing 100Klines of data for my testing.
Revised quicker version
REM
#ECHO OFF
SETLOCAL
SET "sourcedir=U:\sourcedir"
SET /a fcount=199
SET /a llimit=5000
SET /a lcount=%llimit%
FOR /f "usebackqdelims=" %%a IN ("%sourcedir%\q25249516.txt") DO (
CALL :select
>>"%sourcedir%\file$$.txt" ECHO(%%a
)
SET /a lcount=%llimit%
:select
SET /a lcount+=1
IF %lcount% lss %llimit% GOTO :EOF
SET /a lcount=0
SET /a fcount+=1
MOVE /y "%sourcedir%\file$$.txt" "%sourcedir%\file%fcount:~-2%.txt" >NUL 2>nul
GOTO :EOF
Note that I used llimit of 50000 for testing. Will overwrite the early file numbers if llimit*100 is gearter than the number of lines in the file (cure by setting fcount to 1999 and use ~3 in place of ~2 in file-renaming line.)
You can maybe do something like this with awk
awk '{outfile=sprintf("file%02d.txt",NR/5000+1);print > outfile}' yourfile
Basically, it calculates the name of the output file by taking the record number (NR) and dividing it by 5000, adding 1, taking the integer of that and zero-padding to 2 places.
By default, awk prints the entire input record when you don't specify anything else. So, print > outfile writes the entire input record to the output file.
As you are running on Windows, you can't use single quotes because it doesn't like that. I think you have to put the script in a file and then tell awkto use the file, something like this:
awk -f script.awk yourfile
and script.awk will contain the script like this:
{outfile=sprintf("file%02d.txt",NR/5000+1);print > outfile}
Or, it may work if you do this:
awk "{outfile=sprintf(\"file%02d.txt\",NR/5000+1);print > outfile}" yourfile
Syntax looks like:
$ split [OPTION] [INPUT [PREFIX]]
where prefix is
PREFIXaa, PREFIXab, ...
Just use proper one and youre done or just use mv for renameing.
I think
$ mv * *.txt
should work but test it first on smaller scale.
:)
This "File Splitter" Windows command line program works nicely: https://github.com/dubasdey/File-Splitter
It's open source, simple, documented, proven, and worked for me.
Example:
fsplit -split 50 mb mylargefile.txt
My requirement was a bit different. I often work with Comma Delimited and Tab Delimited ASCII files where a single line is a single record of data. And they're really big, so I need to split them into manageable parts (whilst preserving the header row).
So, I reverted back to my classic VBScript method and bashed together a small .vbs script that can be run on any Windows computer (it gets automatically executed by the WScript.exe script host engine on Window).
The benefit of this method is that it uses Text Streams, so the underlying data isn't loaded into memory (or, at least, not all at once). The result is that it's exceptionally fast and it doesn't really need much memory to run. The test file I just split using this script on my i7 was about 1 GB in file size, had about 12 million lines of test and made 25 part files (each with about 500k lines each) – the processing took about 2 minutes and it didn’t go over 3 MB memory used at any point.
The caveat here is that it relies on the text file having "lines" (meaning each record is delimited with a CRLF) as the Text Stream object uses the "ReadLine" function to process a single line at a time. But hey, if you're working with TSV or CSV files, it's perfect.
Option Explicit
Private Const INPUT_TEXT_FILE = "c:\bigtextfile.txt" 'The full path to the big file
Private Const REPEAT_HEADER_ROW = True 'Set to True to duplicate the header row in each part file
Private Const LINES_PER_PART = 500000 'The number of lines per part file
Dim oFileSystem, oInputFile, oOutputFile, iOutputFile, iLineCounter, sHeaderLine, sLine, sFileExt, sStart
sStart = Now()
sFileExt = Right(INPUT_TEXT_FILE,Len(INPUT_TEXT_FILE)-InstrRev(INPUT_TEXT_FILE,".")+1)
iLineCounter = 0
iOutputFile = 1
Set oFileSystem = CreateObject("Scripting.FileSystemObject")
Set oInputFile = oFileSystem.OpenTextFile(INPUT_TEXT_FILE, 1, False)
Set oOutputFile = oFileSystem.OpenTextFile(Replace(INPUT_TEXT_FILE, sFileExt, "_" & iOutputFile & sFileExt), 2, True)
If REPEAT_HEADER_ROW Then
iLineCounter = 1
sHeaderLine = oInputFile.ReadLine()
Call oOutputFile.WriteLine(sHeaderLine)
End If
Do While Not oInputFile.AtEndOfStream
sLine = oInputFile.ReadLine()
Call oOutputFile.WriteLine(sLine)
iLineCounter = iLineCounter + 1
If iLineCounter Mod LINES_PER_PART = 0 Then
iOutputFile = iOutputFile + 1
Call oOutputFile.Close()
Set oOutputFile = oFileSystem.OpenTextFile(Replace(INPUT_TEXT_FILE, sFileExt, "_" & iOutputFile & sFileExt), 2, True)
If REPEAT_HEADER_ROW Then
Call oOutputFile.WriteLine(sHeaderLine)
End If
End If
Loop
Call oInputFile.Close()
Call oOutputFile.Close()
Set oFileSystem = Nothing
Call MsgBox("Done" & vbCrLf & "Lines Processed:" & iLineCounter & vbCrLf & "Part Files: " & iOutputFile & vbCrLf & "Start Time: " & sStart & vbCrLf & "Finish Time: " & Now())
here is one in c# that doesn't run out of memory when splitting into large chunks! I needed to split 95M file into 10M x line files.
var fileSuffix = 0;
int lines = 0;
Stream fstream = File.OpenWrite($"{filename}.{(++fileSuffix)}");
StreamWriter sw = new StreamWriter(fstream);
using (var file = File.OpenRead(filename))
using (var reader = new StreamReader(file))
{
while (!reader.EndOfStream)
{
sw.WriteLine(reader.ReadLine());
lines++;
if (lines >= 10000000)
{
sw.Close();
fstream.Close();
lines = 0;
fstream = File.OpenWrite($"{filename}.{(++fileSuffix)}");
sw = new StreamWriter(fstream);
}
}
}
sw.Close();
fstream.Close();
I have created a simple program for this and your question helped me complete the solution...
I added one more feature and few configurations.
In case you want to add a specific character/ string after every few lines (configurable). Please go through the notes.
I have added the code files :
https://github.com/mohitsharma779/FileSplit

Textfileprocessing by negative value

I got the following textfile. I want to parse trough and put all lines with a negative input in one textfile and all positive in an other. How to manage that ?
help apreciated
39.93120000 14318.98314981793 549.1248138635204
39.93480000 14207.58401258784 533.3688586990800
39.93840000 14668.87500855270 506.8355357433776
39.94200000 14364.81298137747 523.5021767630467
39.94560000 14345.01825913795 522.9223798929314
39.94920000 14266.44146878225 568.0035355907847
39.95280000 14575.20734902781 593.3706907927941
39.95640000 14588.52376078192 610.6837211933131
39.96000000 14332.24884001532 388.5737178283878
39.96360000 14533.92791344165 539.5396926983177
39.96720000 14350.80457814612 510.0423201220646
-39.97080000 14196.71360046875 514.3275994436243
-39.97440000 14051.71265422134 527.4882736778169
-39.97800000 14038.57270550476 503.0691346196745
-39.98160000 14359.74967748116 520.6326881374556
-39.98520000 14710.85875093256 516.4180753359947
-39.98880000 14266.49788517777 690.0481714109405
-39.99240000 14198.67205164648 608.3535256285546
-39.99600000 14417.30585582810 662.5276659319838
-39.99960000 14615.74632666744 599.8846644801356
batch so far, the var test isnt giving me an output of the first character of the line
cls
#echo off
SET sourcefile=sourcefile.txt
for /F "tokens=*" %%A in (%sourcefile%) do (
for /F "tokens=*" %%B in (%%A) do (
SET leadingLetter= %%B:~0,1%
echo %leadingLetter%
)
)
You said you are processing full lines, so this will do what you seem to be asking.
#echo off
find "-" <filein.txt >negative.txt
find /v "-" <filein.txt >positive.txt

Batch file programming: problem with variable

SET SS_SOURCE_PROJECT = sausages
#echo SS_SOURCE_PROJECT = %SS_SOURCE_PROJECT%
This isn't working, it just outputs:
SS_SOURCE_PROJECT =
But I am expecting
SS_SOURCE_PROJECT = sausages
This is on WinXP if it matters. What obvious dumb thing am I doing wrong?
remove spaces:
SET SS_SOURCE_PROJECT=sausages
Yes, batch syntax is terrible.
To expand on #Stefan's answer, the original code works like this: (note the spaces)
C:\>SET SS_SOURCE_PROJECT = sausages
C:\>echo "%SS_SOURCE_PROJECT %"
" sausages"

Resources