0

In my batch file I have this line of code.

FOR /F "eol=; tokens=1,2,3* delims=;/" %%i in ('findstr /v "#" clientsync.cfg') do echo %%l

My current output is

y/IC/draft

Is it possible to get an output like

y:/IC/draft

I would need to insert the : at the second position. Tanks for help!

2 Answers 2

2

Almost done

FOR /F "eol=; tokens=1-4,* delims=;/" %%i in ('
    findstr /v "#" clientsync.cfg
') do echo %%l:/%%m

Just add a new token to separate the element you need and insert the colon and the slash consumed to get the new token

Sign up to request clarification or add additional context in comments.

Comments

1

first: put your output into a variable:

FOR /F "eol=; tokens=1,2,3* delims=;/" %%i in ('findstr /v "#" clientsync.cfg') do set output=%%l

second: use substrings to receate to your needs:

set output=%output:~0,1%:%output:~1%

%output:~0,1% takes a substring, starting from 0 (the first character) with length 1

%output:~1% takes a substring, starting from 1 (the second character) until the end of the string

reference: set /?

1 Comment

An additional reference from ss64.com, "How-to: Extract part of a variable (substring)". This trick is not explicitly on that page, but maybe it should be. :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.