Search
 
SCRIPT & CODE EXAMPLE
 

SHELL

batch script loop

// batch for loop
for /l %%x in (1, 1, 100) do (
   echo %%x
   copy %%x.txt z:whateveretc
)
Comment

for loop batch

for %%variable in (strings/numbers) do( 
	your code 
)  
for /f ["options"] %%variable in (filename) do (
	your code 
)                
for /l ["options"] %%variable in (start_value, increment_by ,end_value) do (
	your code
)
Here ["options"]:
delims=xxx   The delimiter character(s). Default value = a space

eol=;        Default value is ; .If the line starts with ; 
it will be treated as comment and it will
not be printed in the output. 
You can change the Default value to any other character.

tokens=n     Specifies which numbered items to read from each line. 
Default value is 1.
Comment

batch script loop

for /l %x in (1, 1, 100) do (
   echo %x
   copy %x.txt z:whateveretc
)
Comment

batch loop with prompt

@echo off
:main
	:: Put all your code here under the "main" sub-routine
    echo EXECUTED MAIN
    goto rerun_prompt

:rerun_prompt
	ECHO Re-run the script? [Y/N]: 
	SET /p choice=
	IF /I %choice% == Y	goto main
	IF /I %choice% == N (
		echo Exiting...
		EXIT
	)
	ECHO "%choice%" is not valid, try again
	goto rerun_prompt
Comment

batch for loop

for /l %%x in (1, 1, 100) do (
   echo %%x
)
Comment

PREVIOUS NEXT
Code Example
Shell :: permission denied while installing npm 
Shell :: brew apps list 
Shell :: windows port permission denied 
Shell :: install iptables ubuntu 
Shell :: ubuntu open directory from terminal 
Shell :: undo git pull 
Shell :: find bashrc 
Shell :: npm install verbose 
Shell :: pip install google vision 
Shell :: find postgres data directory and installation path 
Shell :: bash command check 2 arguments 
Shell :: ubuntu get ram usage 
Shell :: linux create public key 
Shell :: check timezone linux 
Shell :: Fix the upstream dependency conflict, or retry 
Shell :: update yarn version 
Shell :: access nodeport service from another machine in the same network 
Shell :: mv batch rename extension 
Shell :: rename lxc name on ubuntu 
Shell :: convert p12 to pem 
Shell :: install openssl 1.0 ubuntu 20.04 
Shell :: finding mac address on ubuntu 
Shell :: terminal list items in directory 
Shell :: ubuntu limit cpu on running process 
Shell :: how to debug a specific pod when Replication controller is doing load balancing 
Shell :: get unpushed commits 
Shell :: yarn frozen lockfile 
Shell :: install atom in mac 
Shell :: remove fish shell 
Shell :: linux zip a folder without compression 
ADD CONTENT
Topic
Content
Source link
Name
4+2 =