Skip to content

Instantly share code, notes, and snippets.

@farrrr
Created April 14, 2015 07:40
Show Gist options
  • Select an option

  • Save farrrr/1ce07b2217f810091a1f to your computer and use it in GitHub Desktop.

Select an option

Save farrrr/1ce07b2217f810091a1f to your computer and use it in GitHub Desktop.
Fix dropbox conflict version (use local version)
#!/bin/bash
# XXX: use at your own risk - do not run without understanding this first!
exit 1
# safety directory
BACKUP='/tmp/fix-dropbox/'
# TODO: detect or pick manually...
NAME="MacBook Air"
#NAME='myhostname'
DATE='2015-04-14'
mkdir -p "$BACKUP"
find . -path "* (與 * 衝突的複本 [0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]*" -print0 | while read -d $'' -r file; do
printf 'Found: %s\n' "$file"
# TODO: detect or pick manually...
#NAME='XXX'
#DATE='2014-09-29'
STRING=" (與 ${NAME} 衝突的複本 ${DATE})"
#echo $STRING
RESULT=`echo "$file" | sed "s/$STRING//"`
#echo $RESULT
SAVE="$BACKUP"`dirname "$RESULT"`
echo $SAVE
mkdir -p "$SAVE"
cp "$RESULT" "$SAVE"
mv "$file" "$RESULT"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment