Question

How can I rename all hidden directories under the current directory in DOS? I've just updated Tortoise SVN to use _svn instead of .svn. I noticed that it still works if I just rename the folders.

Was it helpful?

Solution

The following batch file will do the trick, at least on Windows which I hope you are using (no luck in DOS here):

@echo off
call :recurse .
goto :eof

:recurse
for /d %%d in (*) do (
    pushd %%d
    attrib -H .svn >nul 2>&1
    ren .svn _svn >nul 2>&1
    attrib +H _svn >nul 2>&1
    call :recurse
    popd
)
goto :eof

The problem is that ren refuses to rename hidden directories. And for /R seemingly never really works when trying to find directories. So I am building a little recursion through the directory tree here and for each directory I am entering I clear the hidden flag from the .svn folder, rename it, and hide the file again.

Due to re-setting the hidden flag and for /D never returning hidden directories this also has the nice benefit of not attempting to enter the .svn or _svn directories.

OTHER TIPS

This worked better for me as I had a huge number of directories and recursing failed.

FOR /R %%f IN (_svn) DO IF EXIST "%%f" (
    ATTRIB -h "%%f"
    RENAME "%%f" .svn
    ATTRIB +h "%%f"
)
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top