My Tortoise SVN SVN update
command generally returns me this output:
C:\proj>svn update
Updating '.':
A 'some-file1.txt'
D 'some-file2.txt'
Restored 'some-file3.txt'
U 'some'file4.txt'
C 'some file5.txt' B
At revision 123.
Please note that except for the first line (always starting with Updating
) and last line (always starting with At
), each line will always have:
- an action in the first column. This can be a letter or a word
- a file in the second column, wrapped in single quotes. Unfortunately filenames can contain single quotes or whitespaces within them!
- possibly more columns with single letters in them. But I don't care about them.
In a batch file that I am writing, I need to have the actions and files. The actions I manage to get, but the files are too tricky for me it seems. Technically, all I want is everything between the first single quote and the last single quote on the line.
@echo off
setlocal enabledelayedexpansion
for /f "delims=" %%a in ('"svn update"') DO (
set line=%%a
for /f "tokens=1" %%b in ("!line!") do (
set action=%%b
if "!action!" neq "Updating" (
if "!action!" neq "At" (
set file= >>> I DON'T KNOW WHAT TO DO HERE <<<
echo We did !action! to !file!
)
)
)
)
Once this batch file is working correctly, it should output:
We did A on some-file1.txt
We did D on some-file2.txt
We did Restored on some-file1.txt
We did U on some'file1.txt
We did C on some file1.txt