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 prompt loop

@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 :: zip folder linux 
Shell :: switch from npm to yarn 
Shell :: find home dir for user 
Shell :: Delete all running and stopped containers 
Shell :: uvicorn run fastapi 
Shell :: port kill masocs 
Shell :: remove a link linux 
Shell :: Unable to install APK to device. Please make sure the Android SDK is installed and is properly configured in the Editor. 
Shell :: how to add a custom zsh aliases 
Shell :: install kafka windows 
Shell :: linux terminal commands 
Shell :: bash for each line of file 
Shell :: kubectl neat not found 
Shell :: git change local branch name 
Shell :: install python 3.10 linux (multiple python versions) 
Shell :: git update 
Shell :: how to reset all github credentials 
Shell :: docker ftp client 
Shell :: how to write a shell script in ubuntu 
Shell :: git: delete branch in local and on remote 
Shell :: git get commit author 
Shell :: bash check length of variable 
Shell :: download calibre ubuntu 
Shell :: igraph 
Shell :: show commit differences between branches git 
Shell :: install composer by cmd 
Shell :: liburcu ubuntu install 
Shell :: cp bash 
Shell :: How do I run multiple commands on one line in PowerShell? 
Shell :: Invalid response body while trying to fetch 
ADD CONTENT
Topic
Content
Source link
Name
5+3 =