Recursively create folder in specific directories
During a recent backup/restore cycle I've realized that I managed to omit the 'tmp' directories from within the '.svn' directories, and because of this I can't update my working copies. The problem goes away if I manually create a new, empty 'tmp' directory so I am looking for a way to recursively go through each folder, find '.svn' ones and create a 'tmp' folder inside them.
开发者_C百科As I don't want to mess up the existing folders I thought I's ask for help before I did something silly :)
Comments/suggestions will be appreciated, thanks!
PS: This is on a Windows machine so sadly Bash and other unix utilities are not present.
The script above doesn't work on my on Windows 7 machine. The "dir /b /s .svn
" doesn't get all dirs, I get a "File Not Found" error.
I changed the script to have /ad in addition to select directories only and that works! Here is the srcipt which works for me.
@echo off
for /f "usebackq delims=" %%I in (`dir /ad /b /s .svn`) do (
echo Fixing %%I...
mkdir "%%I\tmp"
)
Depends on how many there are.
List the directories with
dir/B/S .svn >dirs.bat
Edit dirs.bat in your editor of choice. Add md
at the beginning of each line (since each line begins with something like C: you can use a fairly dumb editor - including notepad - to change C: to md C:
). Add /tmp to the end of each line (replace .svn
with .svn\tmp
). Save. Run the BAT file
Job done.
Here's how to automate the entire process. Put the following in a file like fixtmp.cmd
:
@echo off
for /f "usebackq delims=" %%I in (`dir /b /s .svn`) do (
echo Fixing %%I...
mkdir "%%I\tmp"
)
精彩评论