Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

FIND: Invalid Switch – not sure what is causing this error

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:

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

[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

>Solution :

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.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading