for /l
is your friend:
for /l %x in (1, 1, 100) do echo %x
Starts at 1, steps by one, and finishes at 100.
Use two %
s if it’s in a batch file
for /l %%x in (1, 1, 100) do echo %%x
(which is one of the things I really really hate about windows scripting)
If you have multiple commands for each iteration of the loop, do this:
for /l %x in (1, 1, 100) do ( echo %x copy %x.txt z:\whatever\etc )
or in a batch file
for /l %%x in (1, 1, 100) do ( echo %%x copy %%x.txt z:\whatever\etc )
Key:/l
denotes that the for
command will operate in a numerical fashion, rather than operating on a set of files%x
is the loops variable
(starting value, increment of value, end condition[inclusive] )
Related Posts:
- What does “@” mean in Windows batch scripts
- Create an empty file on the commandline in windows (like the linux touch command)
- How to solve “The directory is not empty” error when running rmdir command in a batch script?
- How do I create a Batch file to change an exe installer to Win XP SP3 compatibility mode and launch installer
- How to run PowerShell in CMD
- xcopy returns error “Invalid number of parameters” when exclude parameter is set
- While loop in batch
- Curl not recognized as an internal or external command, operable program or batch file
- Redirecting Output from within Batch file
- How to send a simple email from a Windows batch file?
- How can I run a program from a batch file without leaving the console open after the program starts?
- What does /p mean in set /p?
- False ‘Sharing Violation’ Xcopy error message
- batch file from scheduled task returns code 2147942401
- How does the echo command works in batch programming
- CALL command vs. START with /WAIT option
- BAT file to map to network drive without running as admin
- Need auto-restart script in batch for minecraft server
- How to use random in BATCH script?
- Windows batch – concatenate multiple text files into one
- How to set commands output as a variable in a batch file
- Batch command for ImageMagick to convert all files in a directory and sub-directories on windows
- Best practice for exiting batch file?
- how to empty recyclebin through command prompt?
- Why is “MINGW64” appearing on my Git bash?
- Using %PROGRAMFILES(x86)% on Windows OS 32bit
- how to get program files x86 env variable?
- A fatal error occurred while creating a TLS client credential. The internal error state is 10013
- What are good grep tools for Windows? [closed]
- Can’t connect to MySQL server on ‘localhost’ (10061) after Installation
- ow can I find where Python is installed on Windows?
- Setting Windows PowerShell environment variables
- Can’t connect to MySQL server on ‘localhost’ (10061) after Installation
- Why is Windows 32-bit called Windows x86 and not Windows x32?
- How to run a PowerShell script
- How can I open a cmd window in a specific location?
- Python 3.2 Unable to import urllib2 (ImportError: No module named urllib2)
- what is a “dump file” in windows task manager?
- Python 3.2 Unable to import urllib2 (ImportError: No module named urllib2)
- How do I run Redis on Windows?
- Need to navigate to a folder in command prompt
- Using putty to scp from windows to Linux
- Difference between xcopy and robocopy
- ‘npm’ is not recognized as internal or external command, operable program or batch file
- how to open an mp3 file with c
- What languages are Windows, Mac OS X and Linux written in?
- Bat file to run a .exe at the command prompt
- Command Prompt “Net View System Error 6118”
- git clone: Authentication failed for
- How to compile LEX/YACC files on Windows?
- Command ‘ls’ not working in command prompt
- Command line for looking at specific port
- How to uninstall a Windows Service when there is no executable for it left on the system?
- openssh windows bad owner or permissions
- Windows Activator .bat Text
- how to edit or see the source code for dll files
- PermissionError: [WinError 5] Access is denied python using moviepy to write gif
- UnicodeDecodeError: ‘charmap’ codec can’t decode byte X in position Y: character maps to
- Xampp MySQL not starting – “Attempting to start MySQL service…”
- Python 3.2 Unable to import urllib2 (ImportError: No module named urllib2)
- What is the ASCII Code of ½?
- Docker for Windows error: “Hardware assisted virtualization and data execution protection must be enabled in the BIOS”
- Why Local Users and Groups is missing in Computer Management on Windows 10 Home?
- “python” not recognized as a command
- What is Windows Fabric and how to host services in it?
- starting R: Error: ‘\U’ used without hex digits in character string starting “”C:\U”
- What is Windows Fabric and how to host services in it?
- npm ERR! No git binary found in $PATH
- How to open an elevated cmd using command line for Windows?
- SVN admin management GUI tool
- ‘openssl’ is not recognized as internal or external command
- docker error : the input device is not a TTY. If you are using mintty, try prefixing the command with ‘winpty’
- cat not recognised as an internal or external command
- XCOPY: Overwrite all without prompt in BATCH
- Making a countdown timer in C++
- What exactly is the scope of Access Violation ‘0xc0000005’?
- How do you clear the console screen in C?
- How can I do GUI programming in C?
- What is %0|%0 and how does it work?
- Why do fonts appear jagged in Chrome?
- How do I get the current username in Windows PowerShell?
- Visual Studio compiles but the exe isn’t there
- In Windows cmd, how do I prompt for user input and use the result in another command?
- Aliases in Windows command prompt
- Docker hv-sock proxy (vsudd) is not reachable windows
- how to open Jupyter notebook in chrome on windows
- Calling dir in cmd prints out: “Volume in drive C has no label.”
- Difference between $? and $LastExitCode in PowerShell
- How to use/install GNU binutils (objdump)
- In which cases does program exit with 0x40010004 code?
- Sublime Text from Command Line
- Where do you usually have your DirectX SDK folder?
- What is the difference between \ and \\ in file path
- Using %PROGRAMFILES(x86)% on Windows OS 32bit
- “NODE_ENV” is not recognized as an internal or external command, operable command or batch file
- HyperV is not available on Home editions
- What’s a good (free) visual merge tool for Git? (on windows)
- php exec() is not executing the command
- You require permission from “Myself” to delete folder – how to fix
- How to sleep in a batch file?