0

I need to extract versionNo string from recent committed svn log using batch command.

I am using following commands,

cd C:\Program Files\TortoiseSVN\bin\
svn --username user --password pass log -r COMMITTED "SVN_PATH"

and it returns,

------------------------------------------------------------------------
r304 | user | 2019-06-10 17:53:23 +0530 (Mon, 10 Jun 2019) | 2 lines

versionNo - 1.2.3.4 committed for Mantis Id - 0000742
------------------------------------------------------------------------

I am not able to save this command result in a variable and extract this string (1.2.3.4).

3
  • Do you simply wish to assign the string 1.2.3.4 from the posted result to a variable - or do you want to use other aspects of the data? Commented Jun 17, 2019 at 12:00
  • 2
    What have you tried, where are you stuck? Hint: for /F... Commented Jun 17, 2019 at 13:28
  • I just need to assign 1.2.3.4 value to a variable Commented Jun 18, 2019 at 4:33

2 Answers 2

2

To capture the output of a command use the for /F loop.

I think the easiest way would be this:

cd /D "C:\Program Files\TortoiseSVN\bin"

for /F "tokens=2 delims=- " %%L in ('
    svn --username user --password pass log -r COMMITTED "SVN_PATH"
') do @set "VERSION=%%L"

echo/%VERSION%

Since - and SPACE are defined as token delimiters, the hyphen-only = delimiters-only lines are automatically ignored and no particular filtering (using find or findstr) is needed.

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

Comments

1

I would do this, for instance,

setlocal

cd C:\Program Files\TortoiseSVN\bin\

for /f "tokens=3" %%G IN ('svn --username user --password pass log -r COMMITTED "SVN_PATH" ^| find "VersionNo"') do set "v=%%G"

echo %v%

endlocal

Comments

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.