Created
February 29, 2016 03:41
-
-
Save haojianzong/5ab0ce86725f3785154d to your computer and use it in GitHub Desktop.
Svn move bridge for synx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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