#!/usr/bin/bash
for i in `find . -type d -print -name ".svn" | grep -v "/\.svn"`
do
if [ -z "`ls -A $i | grep -v '\.svn' `" ]
then
echo Removing $i
ls -A $i
svn remove $i
fi
done
echo Results:
svn status
Update:
The script above doesn't handle spaces in the filename so use the following two scripts if you have spaces in any filename:
svnPrune.sh
#!/bin/bash
echo Searching...
find . -type d ! -path "*\.svn*" ! -name "\." ! -name "tags" ! -name "branches" -exec /svn/svnPruneDirectory.sh {} \;
echo Results:
svn status
svnPruneDirectory.sh
#!/bin/bash
directory="$*"
#echo Processing $directory ------------------------------------------------------
files=`ls -A "$directory" | grep -v '\.svn'`
#echo files=$files
childrenCount=`ls -A "$directory" | grep -v '\.svn' | wc -l`
#echo $directory: $childrenCount
if [ "$childrenCount" -eq "0" ]
then
echo Removing $directory
# echo $files
svn remove "$directory"
fi
1 comment:
Hey Dude,
Thanks for the inspiration. Here's a small script that prunes and handles filenames with spaces too:
for directory in `find . -type d ! -path '*.svn*' -print0`; do
if [ 0 = `find "$directory" -type f ! -path '*.svn*' 2> /dev/null | wc -l` ]; then
svn rm "$directory" 2> /dev/null
fi
done
One could even turn this into a nice little shell function.
Post a Comment