I am trying to find a specific substring within a string and when I use this code:
For /f "delims=" %%a in (Differences.log) do echo "%%a" | find /I "not admin" do if errorlevel 1 ( DiscordSendWebhook.exe -m "%%a" -n "n0t_k!p" do timeout /t 10 ) else ( Echo Player is not Admin ) do timeout /t 1
It throws this error.
FIND: Invalid Switch
I am using this code to step through a large text file with hundreds of lines that look along the lines of this:
[2022.09.21-03.33.41:653][917]Player Spicejunky#54619 entered movement mode Flying (player is not admin)
It takes the lines and uses the "DiscordSEndWebHook" to send the message into Discord. I am trying to NOT send messages that contain "not admin". This code works just fine when using it without the find statement, but it sends all messages:
For /f "delims=" %%a in (Differences.log) do DiscordSendWebhook.exe -m "%%a" -n "n0t_k!p" do timeout /t 1
CodePudding user response:
For /f "delims=" %%a in (Differences.log) do (
echo "%%a" | find /I "not admin" >nul
if errorlevel 1 (
DiscordSendWebhook.exe -m "%%a" -n "n0t_k!p"
timeout /t 10
) else ( Echo Player is not Admin )
timeout /t 1
)
This will send any not-"not admin" lines to discord (then an 11second timeout) and report player is not admin
for "not admin" lines, then a 1-second timeout.