0

Right now I'm trying to go through my YouTube watch history to find a video I watched years ago, however I don't know the title of it. I got all of my history into a text file so I'm able to load the text file and set "arrays" for each video (name, creator, and date and time it was watched). Right now I have a program that will take a user input string

set /p checkString=

then run it across all of the title variables (that may include ANY character, special character, spaces, and even unicode) one of the title variables would be exactly as follows: "Watched WORKING JAN 2020 Solo Skip ALL Doomsday Heist Setup Missions Easy Glitch | PS4 XBOX1 GTA Online"

echo !currentVideoTitle! | findstr /i "%checkString%" >nul & if errorlevel 1 (
    echo Title contains match
) else (
    echo Title doesn't contain match
)

By using that command, it only ever returns errorlevel 1 and I know that through some level of manipulation my desired outcome is possible such as

if !currentVideoTitle:~%loopCount%,%checkStringLength%!==!checkString!

but that would be massively slower when I'm sorting through roughly 15k videos

  • `@Echo=!currentVideoTitle!|"%__APPDIR__%find.exe" /I "%checkString%">NUL 2>&1&&(Echo Title contains match) Else Echo Title doesn't contain match`, seems like a reasonable method of doing it. However, please note that you haven't shown us the possible content of `!currentVideoTitle!`, so it may be prudent to ensure that it is quoted appropriately, _and your chosen 'find' utility and/or string as necessary_. – Compo Feb 21 '20 at 01:59

1 Answers1

0

I ended up using:

if not "x!var:%in%=!"=="x!var!" (
echo Contains match
) else (
echo Contains match
)

That first bit before the comparison removes any instance of whatever %in% is within the string !var!. The "x" is added to either side to ensure nothing messes up with empty variables etc. This was posted as an answer to another question by the user paxdiablo. I think he/she describes it much better if you want to take a look at the original here's the link: "Original" post, and answer

  • the `x` does not do such things. It's superfluent (some use it to avoid syntax errors with empty variables *and* not using quotes, but the quotes already do that *and* take care of "special characters") – Stephan Feb 21 '20 at 20:53