Delete SVN files in Linux or Windows

Sometimes you checkout a recent API source code via some SVN client to your local system and thereafter want to remove SVN files from the directory structure. Here are the different ways to remove SVN files from your linux or windows directories:

In Linux here is a simple way:

find . -name '.svn' -type d | xargs rm -rf

This searches for all directories which have svn related files. This is a useful command, but might not work as expected if there are hundreds of thousands files on the server. In this case the following command may be useful:

find . -name .svn -prune -exec rm -rf {} \;

For Windows, i know of three different ways to delete svn files.

Way 1 :Using SVN remove command (cmd)

Create a removeSVN.cmd file in the root directory (of which files you need to delete) having the following lines of code in it:

for /f "tokens=* delims=" %%i in ('dir /s /b /a:d *svn') do (
	rd /s /q "%%i"

Now navigate to directory like C:/path/to/directory (using command prompt; how to use command prompt) and type removeSVN and press enter. All SVN files from directory should delete now. Alternately, you can simply navigate to root directory in command prompt and paste above lines as a single line [for /f “tokens=* delims=” %%i in (‘dir /s /b /a:d *svn’) do (rd /s /q “%%i”)] and press enter. Files should delete.

Way 2 : Creating a registry entry

Create a registry file anyname.reg and paste the following code in it:

Windows Registry Editor Version 5.00
@="Delete SVN Folders"
@="cmd.exe /c \"TITLE Removing SVN Folders in %1 && COLOR 9A && FOR /r \"%1\" %%f IN (.svn) DO RD /s /q \"%%f\" \""

(Note:Make sure that last line is in a single line)

Double click on the reg file you just created and agree to everything it asks you for.

Now, right click on the folder you want to delete SVN from and you should see “Delete SVN Folders/files” on the context menu something like this:

Delete SVN files and folders in Windows
Delete SVN files and folders in Windows

Click on the option shown and all SVN files / folders should delete.

Way 3: Search and delete manualy

Right click on the folder name and click Search..
Enter .svn as the filename to search for.
Click “More advanced options” and select:
– Search hidden files and folders
– Search subfolders
Press search button and delete the folders you find appropriate.
(Note: The search critriea may vary in different versions of Windows. Just take note of the thing you want to do exactly.)

Happy SVN deleting!

5 thoughts on “Delete SVN files in Linux or Windows

  1. Creating a registry entry


    is not found , i am on windows7 64bit SP1

Leave a Reply