How to find all SVN working copies on Win XP

Asked by on 2012-03-27T17:50:39-04:00
I have Windows XP. I'd like to upgrade my In order to do that I need to ensure that I can find all SVN working copies on my PC. So they can be updated.

I have found a but it is specific to Powershell. So, I was wondering if there was a more general solution to find all 'SVN working copies' on Win XP.

If I knew the equivalent of 'linux find' on windows I could probably write it myself. But I'm hoping that there may be a bash script out there already (or maybe some solution that's even simpler) that me and others could use.

  • scans the computer
  • if it finds a directory that contains a directory called ".svn"
    • echo that name, and
    • breaks from searching that directory any more

Best Answer

Answered by on 2012-03-27T19:03:27-04:00
To find all .svn files, you can use dir. dir .svn /s will do it (though it won't break from scanning subdirectories) or you can use Windows Explorer and ask the little doggy to find all .svn files.

or you could download and use find after all!

Your Answer
No advertising and No spamming please.

All Answers

Answered by on 2012-03-28T06:49:25-04:00
For complex and powerful searches on Windows-box I can recommend (I use it in real-life)

  • Embedded search inside Total Commander (your have fair evaluation time)
  • GrepWin (with wildcard- and regexp-keywords for filenames patterns)
You miss the point. SVN-clients 1.7 can (and really must) upgrade existing working copies after installing before usage. Also nore: all dirs inside WC for pre-1.6 versions have .svn dirs, you are interested in only every top-most

And later it may be useful for you

1.6 svn-dir

.svn>dir /B
1.7 svn-dir

.svn>dir /B
Answered by on 2012-03-28T13:38:54-04:00
As soon as you have powershell, I could provide my full script to upgrade working copies to 1.7

$prev = "^$"
$workingCopies = Get-ChildItem -Recurse -Force -Include ".svn" -Path "d:\Projects\" |?{$_.PSIsContainer -and $_.Fullname.StartsWith($prev)-eq $false} |%{$prev=$_.Fullname.TrimEnd(".svn"); $prev}

foreach($copy in $workingCopies)
 &"C:\Program Files\TortoiseSVN\bin\svn.exe" upgrade $copy;
I dont had issues with access rights to "System Volume" dir (that was just accidentially, cause I store all my sources in one folder I have full rights to..). As for your issue with Execution Policy - here nice trick to avoid set it forth and back. You could run powershell with special options to avoid issues with execution policy, user specific profile settings (which could be broken for different reasons) etc:

%SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe -NonInteractive -NoProfile -ExecutionPolicy Unrestricted -File “C:\Projects\ConvertSvnToVersion17.ps1”
Also I could clarify what exactly this script do (if you are interested):

$prev = "^$"
Initialize $prev to empty-matching regex - ^$ never match any meaning value (except startline-endline). This was needed to pass initial check

Get-ChildItem -Recurse -Force -Include ".svn" -Path "d:\Projects\" 
Get all objects with name ".svn" (in our case - all files and folders with exact name ".svn"), started from Path, Recursively. And pipe it to next construct:

?{$_.PSIsContainer -and $_.Fullname.StartsWith($prev)-eq $false} 
?{...statements... } is shortcut to "Where-Object" cmdlet, $_ is the way to address "each" entry from pipe. It could be rewritten similar to

foreach($entry in $entriesFromSomewhere)
 If($entry.PSIsContainer -eq $true -and $entry.Fullname.StartsWith($prev) -eq $false)
 "If entry is directory" and "fullname not start with value from $prev"
 ...Pass entry to next construct...
But I wrote it as one-liner for the brevity

%{$prev=$_.Fullname.TrimEnd(".svn"); $prev}
%{} is shortcut for Foreach =) And this construct doing 2 things :

  1. Assign folder fullname without ".svn" tail to $prev
  2. Pass $prev further to next pipeline sink.
And entire result set assigned to $workingCopies as array (any result with more than 1 item will be array)

foreach($copy in $workingCopies)
 &"C:\Program Files\TortoiseSVN\bin\svn.exe" upgrade $copy;
Foreach element in array - execute command (& sign for "execute as command") "…\svn.exe upgrade "

All the magic here is going to that backtracking $prev element: On first ".svn" entry $prev contains non-matching value so first check in "where" will be reduced to "If entry is directory". Then assigning step will put folder parent dir. Ex. If found dir fullname is c:\projects\project1.root\trunk.svn - $prev will be assigned to "c:\projects\project1.root\trunk\". This trick will help us to filter all lower-level .svn dirs: c:\projects\project1.root\trunk\SubProject1.svn entry - will not pass check "not starts with $prev" And this way we will filter only first level .svn dirs, cause all nested .snv will be filtered by StartsWith($prev) -eq $false

So its pretty simple but appears as some magic =)

BTW Thank you for your own answer here - your efforts greatly inspired me to write this comment and clarify entire script.

Grammar geeks should be summoned to this comment for cleaning and rephrasing my "so-called-English" ;)

Answered by on 2012-03-28T09:42:30-04:00
I have managed to find all 'SVN working copies' on Win XP.

I did it using the provided by Alexey Shcherbak.

Here is a summary of the process using the PowerShell method.

Test to see if you have PowerShell already installed. Windows PowerShell is a command-line shell and scripting environment that brings the power of the .NET Framework to command-line users and script writers.

Test to see if it is already installed by attempting to start it.

To start Windows PowerShell from the Run box, click Start, click Run, and type:

If that does not work...

Install it
  • Download Microsoft Windows PowerShell 1.0 for Windows XP from
  • (PowerShell 2 for Windows XP is also available, but I did not use it. ( )
Once its installed...

Start PowerShell and have a play Start > All Programs > Windows PowerShell 1.0 > Windows PowerShell

Create a PowerShell script Copy Alexey Shcherbak's (that finds the svn working copies) into a text file and save it as something like C:\PowerShellScripts\FindSvnWorkingDirectories.ps1.

I modified it slightly to search my C drive and to suppress access denied errors :

$prev = "^$"

Get-ChildItem -ErrorAction SilentlyContinue -Recurse -Force -Include ".svn" -Path "c:\" `
| ?{$_.PSIsContainer -and $_.Fullname.StartsWith($prev)-eq $false}`
| %{ $prev=$_.Fullname.TrimEnd(".svn"); $prev}
Unfortunately I have limited knowledge of PowerShell scripting language, so perhaps some wise expert can edit this answer to explain what this script does in detail.

  • Get-ChildItem, by default, is an alias of the dir command.
  • -ErrorAction SilentlyContinue - Prevents showing errors such as Access to the path 'C:\System Volume Information' is denied
  • -Recurse means search recusively.
  • -Force ensures hidden files are found.
  • -Include ".svn" identifies the filename that we are searching for.
  • -Path "c:\" idientifies the path to search.
  • ` I assume that the backtick means continue the line.
  • | pipes the output of Get-ChildItem into the next cmdlets
  • I don't know what the rest is doing (it looks like a Ternary operation but I'm not sure).
Allow PowerShell to run the script By default, for security, PowerShell's ExecutionPolicy does not let you run PowerShell scripts. So, you need to allow it to do so.

See for more info.

I did the following:

Note: The hash symbol (#) is just shotrthand for the command prompt.

Determine the current ExecutionPolicy:

# Get-ExecutionPolicy
If, like mine, its Restricted. Change the policy to allow a script to run:

# Set-ExecutionPolicy RemoteSigned
Run the PowerShell script Then run the script to find the svn working copies. Note you need to specify the full path to the PowerShell script.

# C:\PowerShellScripts\FindSvnWorkingDirectories.ps1
If there are loads of directories on the PC it may take some time. The results should appear.

Copy and Paste the results to somewhere I did this by selecting the output text with my mouse. Then, to copy it:

Click the PowerShell icon (in the top-left of the Window) > Edit > Copy

Then I pasted it into a text editor.

Revert the PowerShell Excecution Policy to its original state Since I rarely use PowerShell and I loosened the Excecution Policy only to run this, one-off, script I am going to revert it back to its orignal state for security.

Determine the current ExecutionPolicy:

# Get-ExecutionPolicy
Change the policy to revert it to its original state:

# Set-ExecutionPolicy Restricted

So that's how I did it.