jeudi 22 mars 2018

Improve upon duplication check code in batch

This bit of code works great! But is there any way to make it faster? Currently, it outputs fine, but with a slight delay as it is creating and deleting files quite frequently. In the end, the goal is to get it to stop duplicates and it does that but how can it be done more efficiently?

Code:

@echo off

SETLOCAL EnableDelayedExpansion

goto :start

:attackers
set i=0
for %%a in (Vigil Ela Lesion Mira Echo Caviera Valkyrie Frost Mute
            Smoke Castle Pulse Doc Rook Jager Bandit Tachanka Kapkan) do (
   set /A i+=1
   set operator[!i!]=%%a
)
set /a operator=%random%%%i+1
set operator=!operator[%operator%]!
if not exist "ops\" mkdir ops\
if exist ops\%operator%.txt (goto :attackers)
copy /y NUL ops\%operator%.txt >NUL
exit /B

:start
for /l %%x in (1, 1, 5) do (
call :attackers
echo !operator!
)
pause
del /q ops\
goto :start




Aucun commentaire:

Enregistrer un commentaire