Fixing Nextcloud Conflicting Files

2 minute read

I made a bit of a mess with my Nextcloud sync yesterday. I have my Dropbox folder synced to my Mac Nextcloud folder, but not to the sync folder on my NAS. I thought I would save time and bandwidth by copying the folder from my Mac to my NAS and seeing if the sync could figure it out.

It didn’t.

I ended up with loads of conflicts. For example:

james@Jamess-iMac: /Volumes/docker/nextcloud/media/Dropbox/Code/HKWarnings
$ find . -name '*conflict*'
./Classes/AboutViewControlleriPad (conflicted copy 2020-05-03 151942).m
./Classes/AboutViewControlleriPad (conflicted copy 2020-05-03 151942).h
./Classes/AboutViewController (conflicted copy 2020-04-20 100727).m
./Classes/Acknowledgements_iPhoneViewController (conflicted copy 2020-04-28 103701).m
./Classes/Constants (conflicted copy 2020-05-16 172756).h
./Classes/DisclaimerViewController2 (conflicted copy 2020-04-20 100727).m
./Classes/DetailViewController2 (conflicted copy 2020-05-16 172756).m
./Classes/FCReachability (conflicted copy 2020-04-20 100727).m
./Classes/ForecastViewController (conflicted copy 2020-04-20 100727).m
./Classes/GetHistoricalWarnings (conflicted copy 2020-04-20 100727).m
./Classes/GADMasterViewController (conflicted copy 2020-04-20 100727).m
./Classes/HKWWarnings (conflicted copy 2020-04-20 100727).m
./Classes/HKWPhotosViewController (conflicted copy 2020-05-14 193739).h
./Classes/HKWarningsWeatherImages (conflicted copy 2020-05-11 083931).m
./Classes/HKWPhotosViewController (conflicted copy 2020-05-14 193739).m
./Classes/HKWeatherWarningsTabsAppDelegate (conflicted copy 2020-05-16 172756).h
./Classes/HKWeatherWarningsTabsAppDelegate (conflicted copy 2020-05-16 172756).m
./Classes/HomeViewController (conflicted copy 2020-05-03 151942).h
./Classes/HKWeatherWarningsiPadAppDelegate (conflicted copy 2020-05-16 172756).m
./Classes/HKWeatherWarningsiPadAppDelegate (conflicted copy 2020-05-16 172756).h
./Classes/HomeViewController (conflicted copy 2020-05-05 135634).m
./Classes/InAppPurchaseViewController2 (conflicted copy 2020-04-20 100727).m
./Classes/InAppPurchaseManager (conflicted copy 2020-04-20 100727).m
./Classes/InAppPurchaseViewController_iPad (conflicted copy 2020-04-20 100727).m
./Classes/MYUIActivityItemProvider (conflicted copy 2020-04-20 100727).m
./Classes/MyUIActivity (conflicted copy 2020-04-20 100727).m
./Classes/NSDate+HKWUtilities (conflicted copy 2020-04-20 100727).h
./Classes/NSMutableString+HKWUtilities (conflicted copy 2020-05-08 172828).m
./Classes/NSDate+HKWUtilities (conflicted copy 2020-04-20 100727).m
./Classes/NSObject+JSON (conflicted copy 2020-04-20 100727).m
./Classes/NSString_HKWUtilities (conflicted copy 2020-04-20 100727).h
./Classes/NSString_HKWUtilities (conflicted copy 2020-04-20 100727).m
./Classes/PopoverContentViewController (conflicted copy 2020-04-20 100727).m
./Classes/OptOutViewController_iPad (conflicted copy 2020-04-20 100727).m
./Classes/OptOutViewController_iPhone (conflicted copy 2020-04-20 100727).m
./Classes/PushSettingsViewController_iPad (conflicted copy 2020-04-20 100727).m
./Classes/RadarViewController (conflicted copy 2020-05-03 151942).h
./Classes/RadarViewController (conflicted copy 2020-05-03 151942).m
./Classes/PushSettingsViewController_iPhone (conflicted copy 2020-04-28 103701).m
./Classes/RadarViewController (conflicted copy 2020-05-03 151942).xib
./Classes/SatViewController (conflicted copy 2020-05-03 151942).h
./Classes/SatViewController (conflicted copy 2020-05-03 151942).m

In total:

james@Jamess-iMac: /Volumes/docker/nextcloud/media/Dropbox
$ find . -name '*conflict*' | wc -l
     620

Right. I couldn’t fix them manually, or at least didn’t want to.

Script time.

The script below has been though a few iterations, to deal with spaces in filenames/directories, and files without an extension. It mostly works, but some files fail, and maybe some symlinks.

Now:

james@Jamess-iMac: /Volumes/docker/nextcloud/media/Dropbox
$ find . -name '*conflict*' | wc -l
      10
james@Jamess-iMac: /Volumes/docker/nextcloud/media/Dropbox
$ find . -name '*conflict*'
./Apps/Yojimbo/Database.bbyojimbostorage/Contents/Database/Database (Jamess-iMac's conflicted copy 2018-07-07).sqlite
./Apps/Yojimbo/Database.bbyojimbostorage/Contents/Database/Database (Jamess-iMac's conflicted copy 2018-07-07).sqlite-shm
./Apps/Yojimbo/Database.bbyojimbostorage/Contents/Database/Database (Jamess-iMac's conflicted copy 2018-07-07).sqlite-wal
./Apps/Yojimbo/State (Jamess-MacBook-Air's conflicted copy 2020-03-25).plist
./Apps/Yojimbo/State (Jamess-iMac's conflicted copy 2020-01-24).plist
./Apps/Yojimbo/State (Jamess-iMac's conflicted copy 2020-03-25).plist
./Code/HKWarnings-server/1604/etc/monit/conf-available/mysql (conflicted copy 2017-11-28 110223)
./Code/HKWarnings-server/1604/etc/monit/conf-available/rsyslog (conflicted copy 2017-11-28 110223)
./Code/HKWarnings-server/nginx-config.io/sites-enabled/01_stouty.xyz (conflicted copy 2019-10-11 110101).conf
./Code/HKWarnings-server/nginx-config.io/sites-enabled/02_hkwarnings.com (conflicted copy 2019-10-11 110125).conf

The last 4 are symlinks. Not sure about the others.

Here’s the script: