Reputation: 13
I am trying to get part of string from a file and write it into a variable using win CMD, but the file have a few strings, and I need only part of the third string. For example, file "myfile.txt" contain next strings:
package:com.test0.android
package:com.test1.android
package:com.test2.android
package:com.test3.android
And I need to write only "com.test2.android" in to a variable, but I can't find solution how to do this. Can anybody help me please?
Upvotes: 0
Views: 2254
Reputation: 41257
Try this:
@echo off
for /f "tokens=1,* delims=]" %%a in ('find /n /v "" ^< "myfile.txt" ^| findstr "^\[3\]" ') do set "variable=%%b"
echo "%variable%"
Upvotes: 1
Reputation: 29369
Not sure if this is what you are looking for. But give it a try
set str=package:com.test0.android
set str=%str:package:=%
Upvotes: 0