Edit: Assuming the part you are trying to extract is of variable length, this seems like an even better solution:
set str=street-ct-2a21340565364563563 for /f "delims=-" %%a in ("%str%") do set part=%%a echo.%part%
In this snippet, we break the line whenever " - " occurs, and then assign the first part of the split line to the variable " part ". Additional examples of how to use for to separate lines can be found here .
According to this link you can do something like this:
set str=street-ct-2a21340565364563563 set substr=%str:~0,6% echo.%substr%
source share