If you’re a Mac user, you may be familiar with the DS_Store file.
Hidden DS_Store and ._ files are the number one most common hidden files across Google Drive accounts. It makes sense, as Apple shipped over 17% of all personal computers in the United States last year. That’s a lot of DS_Store files being generated every day.
You may also have seen something concerning in the news last year and might be concerned about it happening again.
What am I talking about? Let’s dig in.
What are DS_Store and ._ Files?
No, we’re not talking about a shop for a defunct Nintendo DS handheld. DS_Store, or more appropriately, “.DS_Store” (the dot is important), is a file you see everywhere – or not at all, if it’s hidden. There may also be a lot of ._ files that are nearly identical to a file name on your system except it has a ._ in front of the name. For example, if you have a file name photo.jpg you may also have a file named ._photo.jpg. Last, you may even see a variation called “._.DS_Store”, which is created if the filesystem doesn’t support the file or folder metadata.
Specifically, it’s a hidden file created by Mac OS’s Finder (the equivalent of File Explorer in Windows, for the Windows users out there).
That means it’s something Windows users only see if they deal with content from Mac users.
The quirk here is that it’s an invisible file. Now, that’s not unusual; Windows and Mac make files invisible to their file-exploring software by default. They do this because the files are generally not something a standard user ever needs to deal with.
These operating systems make the files invisible to prevent computer-illiterate or semi-literate users from unintentionally damaging their devices. You have no reason, in everyday use, to ever care about these files. Or in some cases, tampering with the files can corrupt other files, make programs non-functional, or break your system entirely.
The trouble is with the “.DS_Store” files on Mac. These files are created by Finder every time you view a folder, which means they’re in every folder you look at. They contain metadata about the folder they’re in, including information about the files in that folder, configuration preferences, and more. Usually, there’s nothing wrong with that.
Finder wants access to information in a way it can use to maintain user preferences in an easy-to-read location.
Windows computers do a similar thing with .ini files, like Desktop.ini, which governs where icons are placed and how they’re displayed.
What’s the Problem with DS_Store & ._?
The problem with “.DS_Store” and ._ is not how your computer uses it. Instead, it’s how it uses it when you’re not paying attention or don’t even know that those files are there.
Say, for example, you have a folder full of images you want to send to a friend. You zip up that folder in an archive and send it to them.
They receive it, extract it, and ask you: “What’s this DS_Store thing?”
DS_Store is a file in your folder, and when you zipped it up into an archive and sent it to a friend, that file came along for the ride. But it’s invisible to you by default. However, Windows users can see it plain as day because it’s not hidden from their operating system. Likewise, anyone who has the OS-level “view hidden files” option checked can see it regardless.
So, now you’ve sent a user some configuration information about your macOS folder.
Great! How big of a problem is this?
The answer is a firm “it depends.” It’s not exactly personal information in general. No one can hack you because they know you view your folder as a list rather than thumbnails. But the .DS_Store file has been used in bug-based attacks in the past and can provide some information, like file presence and folder structure, that a malicious actor could take advantage of in the right situation.
What Does This Have to Do With Google Drive?
There are a few reasons why this is all relevant to Google Drive.
The first is that the .DS_Store file is a file created in any folder you view with Finder, including folders on your Google Drive for Desktop installed on your Mac. When you browse that folder, Finder makes that DS_Store file, which Google Drive helpfully syncs with the cloud.
This means the information in that DS_Store file is now stored on the cloud, where anyone with access to your Google Drive can see it. Now, that’s not usually an issue outside of extreme circumstances because anyone with access to your Drive can see everything the file would contain anyways.
But, it can be an issue if you add another folder from your computer to Google Drive, bringing its own DS_Store file with it.
The second reason why this can be an issue is that the DS_Store file takes up space. It’s very little space – the file is generally only a few kb in size. But that can add up when you have thousands or tens of thousands of folders. Imagine that you have a Google Drive with 10,000 nestled folders, each with an invisible 6kb file. That’s over 50 megabytes of space taken up by stuff you can’t see, use, or quickly delete!
The third reason is something that is both extreme and rare. In fact, it’s relatively unlikely to ever happen again. But it happened once, and it was hugely disruptive for many people, and there’s no way to know that it will never happen again. So, what was the problem?
Google Drive, at some point, started flagging the DS_Store file as a copyright violation.
This issue lasted for a short time and was resolved by Google’s team quickly. No one is really sure why it happened, though the current theory is that some bot detecting duplicate files across a wide range of accounts based on their hash checksum (a unique code generated by the file when run through an algorithm) flagged millions of accounts as having the same file, which isn’t something that’s generally likely to happen on its own.
Then, at some point, something – a bot or a person – erroneously decided that the file was copyrighted material, and not owned by all of these accounts holding it, so they flagged it and issued copyright notices to those users. This error led to a lot of users getting copyright flags for files they often didn’t even know existed. Obviously, that’s a pretty big problem!
Now, again, this was a one-time event that happened about a year ago and is pretty unlikely to repeat itself. No one was permanently punished for it, and while it may have caused some stressful days for account managers, it didn’t amount to anything. Still, why not be safe instead of sorry and get rid of the files?
What Happens if You Delete DS_Store or ._?
So, we know that .DS_Store and ._ is a configuration metadata file used by Finder. The question is, what happens if you delete it?
As you might have guessed, the answer is that Finder loses access to that information, so things like the thumbnail previews of files, the position of icons on a desktop or in a folder, and viewing preferences for the folder are all lost.
But here’s the thing: Finder wants to have that information accessible. So, when you delete the file, Finder automatically recreates it.
It’s not necessarily a bad idea to delete the file, though. For one thing, the .DS_Store file can get huge in frequently-used areas like your desktop or root directories. That’s because it stores information about files even after you remove those files, in case you put them back. Deleting the file will generate a new version based on current settings and files in the folder, which is often smaller (and even sometimes much smaller) than before.
There are also a few tertiary quirks that could be relevant.
- File comments added through Finder will be lost to Finder if you delete the file because that’s where they’re stored. They’re also stored in the file’s extended file attributes, but since Finder doesn’t check there, you’ll have to dig if you need information in the comments.
- Similarly, if you have very positional use of Finder (the “Spatial Finder” habits of old-school Mac users), that information can be lost. These are generally edge cases for the most common modern use of Macs, though.
- Lastly, you can use “Command + Shift + .” on macOS to show hidden files, but this doesn’t work with the .DS_Store file in Finder. The .DS_Store file is still there, but the operating system hides it. You’ll have to use third party software to discover and remove those files once you disable them from re-appearing.
So: you can delete .DS_Store with mostly nothing of value lost, and you can save some space by doing so, but the file will generally be re-created on your Mac if you’re using Finder to view that folder.
The .DS_Store file is only automatically re-created on macOS, not on other machines. You can safely remove those files on a Windows machine or on the Google Drive cloud.
How to Delete DS_Store
If you want to delete DS_Store, it’s pretty easy, depending on how you want to go about it.
1. From Your Mac
If you’re on your Mac and you want to delete DS_Store, you’ll need to do so through the Terminal.
If you try to delete it through Finder, it will just come right back.
There are a couple of options here.
The first is to tell your Mac to show you invisible files and then use a non-Finder app to view the folder and delete the DS_Store file. Simple, easy, and won’t linger once you view the folder again. It also requires you to go to each folder where you want to delete the file, which could be a specific folder, or it could be every folder on your device.
That’s a lot of files!
The second option is a wide-ranging Terminal command. Here it is:
sudo find / -name '.DS_Store' -delete
Note: You should never run random scripts from the internet, especially ones with “sudo” in them, without knowing what they do.
So, let’s break this down.
- sudo – this means the command is run from top-level permissions and overwrites local permissions telling you that you can’t do something. This command allows you to delete files you shouldn’t otherwise be able to delete, so be very careful with it!
- Find – find files that match the parameters.
- / – use the root directory of the computer as the starting point.
- -name – find files using the specific name specified in quotes, in this case “.DS_Store”
- delete – the command is to remove them.
So, this command will execute at the administrator level, scan the entire computer through every folder, identify every DS_Store file, and delete them. They won’t auto-regenerate because you aren’t using Finder to find them.
Note: You can also create a script that runs regularly and purges all DS_Store files if you want. Instructions can be found here.
2. From Google Drive
Since Google Drive can see these files without having to make them visible first, you need to use the Google Drive search function to find all files with the name “.DS_Store” and delete them.
If you use the Google Drive app on your other devices, you can also use search your local Google Drive directory on a Windows machine to find and remove these files.
3. With Filerev
If you’re using a Mac and your .DS_Store files are hidden from you, you can use Filerev to show all hidden files and data on your Google Drive and purge any or all of it. You’ll be surprised at all of the junk data floating around your account eating up your storage space.
This is a much easier method than manually deleting thousands of these files one by one. It’s also safer than bulk deleting files on your machine using sudo delete commands. If you’re on a Mac and you’re not comfortable with Linux commands, well… I’m sure you’ve heard of the horror stories. Toy Story 2 was almost scrubbed from existence due to an accidental sudo delete command and they had to piece it back together from backup drives.
Filerev now lets you sort by file extension, too, and you can create a filter to show you all of your “.DS-Store” or ._ files. There are also date filters, so you can show “Files that are one year old” and file names that match “.ds-store”.
You can also view your other files that don’t have a file extension or hidden files that start with a period / dot. To do this click the “Type” drop down and then select “No file extension” or “. (dot)” and you can see all of your temporary and hidden files.
You can also do various other cleanup tasks with Filerev, so I highly recommend checking it out.
Prevent Finder from Making More DS_Store Files
Since the biggest issue with DS_Store is that they keep coming back, is there a way to tell Finder to stop making them? As it turns out, yes.
Once again, from Terminal, you want to execute a command. In this case, you want this:
defaults write com.apple.desktopservices DSDontWriteNetworkStores true
This command is more plain English than the terminal script above. It sets a new default telling Apple’s Finder not to write DS_Store files to network shares. DS_Store will still write to regular folders in your computer, though, and there’s not really a good way to turn that off.
You can also find specific solutions in edge cases. For example, if you’re a developer and you have a problem with Git uploading and syncing your DS_Store file, you can add the file name to your .gitignore file so it won’t be synced.
Between the auto-delete scripts, Filerev, and other solutions, you should be able to manage DS_Store files with relative ease. They can still show up occasionally, but it won’t be devastating when they do, and you can remove them quickly and easily.
Do you have other questions about Google Drive or finding and removing hidden files? If so, drop me a line or let me know in the comments section below, and I’ll do what I can to help you out.