Skip to content

Instantly share code, notes, and snippets.

@haojianzong
Created February 29, 2016 03:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save haojianzong/5ab0ce86725f3785154d to your computer and use it in GitHub Desktop.
Save haojianzong/5ab0ce86725f3785154d to your computer and use it in GitHub Desktop.
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