Skip to content

Instantly share code, notes, and snippets.

@tommydangerous
Created July 31, 2014 18:53
Show Gist options
  • Select an option

  • Save tommydangerous/9b5d3ac9c3dd55e30179 to your computer and use it in GitHub Desktop.

Select an option

Save tommydangerous/9b5d3ac9c3dd55e30179 to your computer and use it in GitHub Desktop.
Fix Dropbox conflicted files
#!/bin/bash
folder=/users/tommydangerous/dropbox/rails_projects/ombrb
clear
echo "This script will climb through the $folder tree and repair conflict files"
echo "Press a key to continue..."
read -n 1
echo "------------------------------"
find $folder -type f -print0 | while read -d $'\0' file; do
newname=$(echo "$file" | sed 's/ (.*conflicted copy.*)//')
if [ "$file" != "$newname" ]; then
echo "Found conflict file - $file"
if test -f $newname
then
backupname=$newname.backup
echo " "
echo "File with original name already exists, backup as $backupname"
mv "$newname" "$backupname"
fi
echo "moving $file to $newname"
mv "$file" "$newname"
echo
fi
done
find $folder -name '*.backup' -delete
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment