Sunday, January 03, 2016

.AppleDouble files on Linux

To get rid of those .AppleDouble files which OSX creates when accessing folders on Linux, first disable the creation of these files

defaults write com.apple.desktopservices DSDontWriteNetworkStores true

Then use the following script to remove every .AppleX file created:

#!/bin/bash

if [ -z "$2" ]
       then
               echo "Use --really to remove appledoubles"

fi

if [ -z "$1" ]
       then
               echo "No arguments supplied"
               echo "Use --really to remove .AppleDouble files"
               exit 1
       else
               find $1 -name .AppleDouble -exec ls -d {} \;
               find $1 -name .AppleDesktop -exec ls -d {} \;
               find $1 -name .AppleDB -exec ls -d {} \;
fi

if [ "$2" == "--really" ]
       then
               echo "RUNNING DELETE"
               find $1 -name .AppleDouble -exec rm -r {} \;
               find $1 -name .AppleDesktop -exec rm -r {} \;
               find $1 -name .AppleDB -exec rm -r {} \;
               echo "Done. .AppleDouble files obliterated\n"
       else
               echo "nothing"
fi