Delete files starting with ._ using the terminal
I have always had an issue when copying files from macOS to a windows formatted drive, that I would suddenly find loads of files with the same name but hidden starting with '._'.
So how can we remove all these files, well my first thought was to show all the hidden files on macOS using the terminal but guess what they still didn't show.
What about opening the directory using an application which allows you to see all the hidden files like 'Atom' and delete them this way, well first if they are in subdirectories this could be time consuming plus another problem happens - macOS doesn't recognize they are in the trash so you still can't delete them!
As per usual with most of these issues it can be solved completely 100% in the terminal.
So here is how we can remove all those files starting with '._'?
The input below searches for files starting with '._' and then lists them all.
find . -type f -name "._*" -print
But the more important part is how to delete them... well that is simple enough.
find . -type f -name "._*" -delete
Plus if you want to list the files which have been deleted use this.
find . -type f -name "._*" -print -delete
I hope this solves the problem I had for ages but thank goodness I found this solution.
Visitors also viewed these posts