Esta es la contestación más completa que encomtrarás compartir, pero mírala detenidamente y analiza si es compatible a tu trabajo.
Ejemplo 1: bucles por lotes
set LoopVar=0
:Loop
echo %LoopVar%
set /a LoopVar=%LoopVar%+1
if not %LoopVar%==100 goto Loop
echo Done!
pause
------------------------------------
HOW IT WORKS
------------------------------------
set LoopVar=0 <--- Sets the counter to 0
:Loop
echo %LoopVar% <--- Echos Status
set /a LoopVar=%LoopVar%+1 <--- Adds +1 to the Var "LoopVar"
if not %LoopVar%==100 goto Loop <-- Until "LoopVar" equals 100 it repeats the job. (You can change the 100 to any number you would like.)
echo Done!
pause
Ejemplo 2: bucle de script por lotes
for /l %x in (1, 1, 100) do (
echo %x
copy %x.txt z:whateveretc
)
Ejemplo 3: cmd para bucle
REM # | EXAMPLE: For loop to copy all the files in the current directory to the C:User folder
For %F in (*) do copy %F C:User
REM # | SYNTAX
REM # | For %F in () do
REM # | NOTE: you can use the following to extract specific parts of a filepath
REM # | take note that this syntax only works when run from a batch file
@echo off
setlocal
set file=C:Usersl72rugschiriDesktopfs.cfg
for %%N IN ("%file%") do (
echo filedrive=%%~dN
echo filepath=%%~pN
echo filename=%%~nN
echo fileextension=%%~xN
echo default=%%N
)
Ejemplo 4: ventanas de lote para
syntax-FOR-List of numbers
FOR /L %%parameter IN (start,step,end) DO command
syntax-FOR-Command Results
FOR /F ["options"] %%parameter IN ('command to process') DO command
¡Haz clic para puntuar esta entrada!
(Votos: 0 Promedio: 0)