latexdiff + svn not working with multiple files (flatten)

I've written a very simple Windows batch script (latexdiff-svn.bat) that automated my described workflow. It exports a given revision of the the svn working copy to a temporary folder (typically under C:\Users\username\AppData\Local\Temp), performs latexdiff --flatten, and deletes the temporary folder.

The actual barebones script is only 5 lines

:: Usage: 
::      latexdiff-svn <svn revision number> <filename>
set tempfolder=%TEMP%\latexdiffsvn
rmdir /s /q %tempfolder%
svn export -r %1 . %tempfolder%
latexdiff --flatten %tempfolder%/%2 %2 > diff-%2-r%1.tex
rmdir /s /q %tempfolder%



And below a slightly more elaborated version that does some basic checking on the parameters, and provides some friendly clues to the user. You can copy-paste the code in a file named for example 'latexdiff-svn.bat'

:: Usage: 
::      latexdiff-svn <svn revision number> <filename>
:: e.g.
::      latexdiff-svn.bat 23 main.tex

::Some basic checks on the arguments
@if "%1"=="" goto not_enough_parameters
@if "%2"=="" goto not_enough_parameters
@if not exist %2 goto file_does_not_exist
@svn info -r %1 > NUL
@if errorlevel 1 goto revision_does_not_exist
@goto all_seems_ok

:not_enough_parameters
@echo.
@echo I need exactly two arguments, the first one specifying 
@echo the svn revision number, the second one the file name.
@echo Example syntax:
@echo    latexdiff-svn 23 main.tex
@goto :EOF

:file_does_not_exist
@echo.
@echo I couldn't find the file you specified: %2
@goto :EOF

:revision_does_not_exist
@echo.
@echo The current folder does not contain an svn working copy, 
@echo or the revision number specified (%1) does not exist
@goto :EOF

:all_seems_ok
@set tempfolder=%TEMP%\latexdiffsvn
@set difffile=diff-%2-r%1.tex
@if exist %tempfolder% rmdir /s /q %tempfolder%
@echo Creating temporary folder at revision %1
@svn export -r %1 . %tempfolder% > NUL
@echo Running latexdiff
latexdiff --flatten %tempfolder%/%2 %2 > %difffile%

:cleanup
@if exist %tempfolder% rmdir /s /q %tempfolder%

@echo.
@echo Written to: %difffile%
@echo Done !

Note: the latexdiff script used with the --flatten option outputs a few DEBUG lines. If you want to suppress these (without fixing the perl script itself), see the solution to this stackoverflow question: https://stackoverflow.com/questions/11362041/how-to-suppress-specific-lines-in-windows-cmd-output


From version 1.1.0 latexdiff-vc actually supports use of the --flatten option for SVN by temporarily checking out the old version in a separate directory. The limitations of the --flatten option alluded to by Jörg's comment to another answer also are no longer there in newer versions of latexdiff.