SVN Scripts for managing several folders

You may find that you have several directories all connected to (Subversion) SVN so that their code, scripts, xml, ini files etc can all be managed under Subversion source control (http://subversion.apache.org/).
 
It’s possible that you have this repeated on several servers!
 
Here’s a nice script that will check your directories to see if they are currently managed by SVN.
If they are, then the script will svn update the directory.
If they aren’t, then the script will svn checkout the directory.
 
You can add as many directories as you want to this.
 
This saves me loads of time when building new app servers.
 
<pre>
@echo off & setlocal enableextensions
cls
 
rem ******************************************************
rem * Update directory structure for all SVN repos
rem *
rem * Kieran Caulfield, June 2012. Excelian Ltd.
rem *
rem ******************************************************
 
echo This will update all svn attached directories.
rem pause
 
Set drive=D:
 
%drive%
echo Drive is set to %drive%
 
Set SVN_User=”kieran.caulfield@mycompany.com”
 
echo Updating SVN Directories…
rem *********************************
 
set myFolder=D:\MyScripts
set svn_URL=”https://mycompany.jira.com/svn/MYPROJ/trunk/MyScripts”
Call :SVN_Folder
 
 
set myFolder=D:\MyScripts2
set svn_URL=”https://mycompany.jira.com/svn/MYPROJ/trunk/MyScripts2″
Call :SVN_Folder
 
set myFolder=D:\CrystalReports
set svn_URL=”https://mycompany.jira.com/svn/MYPROJ/trunk/CrystalReports”
Call :SVN_Folder
 
echo Please check results and press any key to end….
pause
 
GOTO End
 
rem *****************************
:SVN_Folder
rem *****************************
 
if exist “%myFolder%\.svn” (
echo folder %myFolder%\.svn already exists – SVN UPDATE
echo D:\TortoiseSVN\bin\svn update “%myFolder%”
svn update “%myFolder%”
)
 
if not exist “%myFolder%\.svn” (
  echo folder %myFolder%\.svn not found – SVN CHECKOUT %SVN_URL%
  echo svn checkout %SVN_URL% “%myFolder%” –username %SVN_User%
svn checkout %SVN_URL% “%myFolder%” –username %SVN_User%
)
 
GOTO :EOF
rem *******************************
 
:End
</pre>
 
 
Note, I use the Tortoise SVN Client, it’s brilliant.
http://tortoisesvn.net/

Leave a Reply