Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Svn move bridge for synx
#!/bin/sh
# This script move files from an old directory into a new dirctory
# using the file hierarchy from a reference directory, while preserving svn
# log history.
# The purpose is to organize files in one place and do 'svn mv' after
# you have finished organizing. In this way you don't need to worry about other
# developers commiting files while you are moving files around.
# old directory
olddir=Classes
# reference directory
refdir=Classes_ref
# new directory
newdir=Classes_new
files=$(find $olddir -type f)
# for files in olddir, recursively find path according to their counterpart in refdir
# then place them in newdir using svn mv
for oldpath in $files; do
filename=$(basename $oldpath);
# echo $filename;
# new path
# find in refdir and awk to newdir
newpath=$(find $refdir -type f -name $filename | sed "s/$refdir/$newdir/g")
# echo $newpath
# svn mv the file
# will create directory if necessary
svn mv --parents "$oldpath" "$newpath"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment