Created
July 31, 2014 18:53
-
-
Save tommydangerous/9b5d3ac9c3dd55e30179 to your computer and use it in GitHub Desktop.
Fix Dropbox conflicted files
This file contains hidden or 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/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