简体   繁体   中英

Getting a set of revisions from SVN in Windows batch script

I'm writing a script for synchronisation of SVN repositories. It's my first Windows batch script, so I have some problems with it. I use "svn log -q" command which gives revision numbers like this that are stored in SVN_LOG_Q_FILE:

------------------------------------------------------------------------
r4 | username | 2011-05-26 13:31:04 +0100 
------------------------------------------------------------------------
r3 | username | 2011-05-26 13:27:33 +0100 
------------------------------------------------------------------------
r2 | username | 2011-05-26 15:39:29 +0100 
------------------------------------------------------------------------
r1 | username | 2011-05-26 13:37:41 +0100 
------------------------------------------------------------------------

What I'd like to get is only revision numbers. I use below code for getting revisions, but they're with leading "r" (r1, r2 etc.).

for /f "usebackq tokens=1" %%g in (`findstr /r /c:"r" %SVN_LOG_Q_FILE%`) do (
    echo rev %%g%
)

Can you help me?

Thanks in advance, szeldon

A simple FOR /F with the delims <space> and r should work, as there is always a space behind the r.

for /f "usebackq tokens=1 delims=r " %%g in ("%SVN_LOG_Q_FILE%") do (
    echo rev %%g
)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM