Bill Morefield My thoughts, discoveries, and occasional rambiings.

September 2, 2009

Renaming Folder Names from _svn to .svn in Subversion

Filed under: Uncategorized — Bill Morefield @ 6:26 pm

At one time Visual Studio didn’t like folders that started with a period.  Unfortunately Subversion uses a folder name .svn to store information by default.  As a workaround most Subversion and Subversion clients for Windows allowed users to set an environment variable (and the TortiseSVN client would do this for you) to use and underscore in place of the period so .svn became _svn.

So tonight I was getting around to finally setting up the development environment on my new Windows 7 laptop (and so far I love it) and moving the projects backed up from my old machine to my new one.  When I opened one up to work on it, I found that it didn’t seem to recognize that it was a local copy of a project.  Some investigation showed that the old laptop had this variable set, so it was looking for _svn instead of .svn for the information.

Most likely when I moved to my last laptop I set this variable as I still had one old ASP.NET 1.1 project that I maintained and simply left it that way even though I haven’t touched the project in two years.  Or I just set the variable so that the old files that had already been checked out with the variable set on its predecesor would work.  Now though I wanted to make a change and it seemed there had to be an easier way than going through all the sub folders in each project, unhiding each _svn folder, renaming it, and then hiding the renamed .svn folder back.

Sure enough at this site I found a batch file to do just that.  The back file is simply:

FOR /R %%f IN (_svn) DO IF EXIST "%%f" (
ATTRIB -h "%%f"
RENAME "%%f" .svn
ATTRIB +h "%%f"
)

I repeat the warning on that page that it works for me, but you use at your own risk.

4 Comments »

  1. Great insight! That\’s the awnser we\’ve been looking for.

    Comment by Jennica — January 8, 2012 @ 9:15 pm

  2. That’s great apart from the re-hiding of the directories. It is trying to hide “_svn” when it has already been renamed to “.svn”

    Comment by Greg Bacchus — February 12, 2012 @ 7:09 pm

  3. You are correct and I didn’t notice it when I originally posted this. Unfortunately I do not have an updated script as I’ve moved to Mercurial for version control since then.

    Comment by bill — February 15, 2012 @ 3:44 pm

  4. You can use the following to hide all the new .svn directories AFTER you have run the first batch file

    FOR /R %%f IN (.svn) DO IF EXIST “%%f” (
    ATTRIB +h “%%f”
    )

    Or if you haven’t already run the first one the following should work to do the whole job

    FOR /R %%f IN (_svn) DO IF EXIST “%%f” (
    ATTRIB -h “%%f”
    RENAME “%%f” .svn
    )
    FOR /R %%f IN (.svn) DO IF EXIST “%%f” (
    ATTRIB +h “%%f”
    )

    Comment by lee — June 27, 2014 @ 3:07 pm

RSS feed for comments on this post. TrackBack URL

Leave a comment

Powered by WordPress