If you use a Mac and Windows together, you’re likely to end up with a bunch of hidden .DS_STORE files all over your Windows drives. You can easily search and destroy them all using this command:
(Open the command line first of course. You can do this by mashing Win + R, then typing “cmd”. Or just type “cmd” in the Start Menu search box.)
del /s /q /f /a .DS_STORE
That will find every instance of this Mac resource file and delete it. Good times. But wait there’s more. In addition to DS_STORE, OSX will also put a bunch of other junk every where starting with “._”. Kill those like this.
del /s /q /f /a ._.*
(Why not use “._*'” instead? Apparently, you can sweep up legit files from other things such as Chrome by doing that. Thanks, commenters.)
Important note! This will only search inside the folder you’re in, as well as every folder below that. So, if you wanted to search and clean an entire drive, make sure you’re in the root folder. Get there with this:
You could also put all of this into a .bat file for great automation.
Pro tip: copy-pasting into your command window
Windows 10 will let you CTRL-V paste into the command line. Friggin sweet. But did you know you can do it in other versions of Windows too? Just right-click on the command window and click Paste. That will save you a little work.
Thanks for this.
So if I want to remove the ._filename garbage that OSX scatters after every file open as well, would it be:
del /s /q /f /a:h ._*
It sure does! I just tested it.
this command is not working on my PC. it says: “Could Not Find C:\.DS_Store”. But there are lot of .DS_Store file accessing through Mac to Windows.
Same here as mentioned by crowdyR – I get the same exact message (I am running a Windows 7 Ultimate OS). I know for a fact that I have at least 4 .DS_Store files as well.
…. Oh, but the “del /s /q /f /a:h ._*” command worked – Thanx 🙂
Thank you very much for this!
del /s /q /f .DS_Store
and it will work.
This has helped keep my sanity. I was able to delete 19,617 ._* and .DS_STORE files! (I know this amount because when I backup, I exclude all ._ files, yet I was not able to delete them from the source side) Thank you so much.
19,617 — That’s definitely a lot. Very glad I could help!
I just tried it and it works! Thank you so much for this amazing tip! I heard some beeping sound though, twice. Wonder what that was.
don’t do ._* as what to be deleted! you end up deleting a bunch of pref files for google chrome. the files you want deleted have ._. so make sure you add an extra . to ._ THAT’S WHY you had 19k files deleted! you deleted stuff you might have needed.
stick to ._.* not ._* k good.
I’m running Windows 7 and the comment left by @uau worked for me:
del /s /q /f .DS_Store
Thanks this worked great
[…] you're on Windows, you can delete the files at the Command Prompt using the command below (obviously you'll need to change to the relevant drive letter […]
Thanks for this. Was driving me crazy having all these random useless files showing up.
We ran this cmd and have now lost every file. Did we do something wrong? The files don’t even show up in the “recycle bin”.
Awesome…Thanks a lot, this is exactly just what I need 😀
It worked like a charm! Thank you. Of course you can use also cd if you want to clean only one folder:
del /s /q /f /a:h ._*
Here there are no limits to your fantasy 🙂
the del /s /q /f /a:h ._* worked like a charm!!! just make sure you have selected the root folder for all the files you want deleted…win 8
For those who still have .DS_Store files after running command, it is possible that the file is no longer hidden. Just remove the /a:h. I now have both commands in my batch file and it removes all. (del /s /q /f *.DS_STORE)
I am really grateful for this-it did indeed work like a charm. However I do have some files which have the ~$ remainimg-any hel with that?
Good one, saved me hours of work 🙂
instead of using /a:h which mean it require that the file has to have attribute hidden, use just /a instead, this would simply mean regardless of what the attribution the file has. This mean, the deletion command is better w/ just
del /s /q /f /a .DS_STORE
There is no need to do two separate commands.
That said, I would prefer just ‘del /s /f /a .ds_store’ no quote. or maybe even add >sometextfile.txt to export the output instead to keep the log just incase you need that info later.
Why is it givingme an error that the drive i did could not find?
The command worked perfectly but now I have some empty folder that I can no longer delete and some I can no longer access.
I need to remove the folders as well but nothing seem to be working
any help please?
My troubles running these stemmed from encoding issue. I was saving as UTF-8. Once I changed to ANSI it worked just fine. Maybe this is a given, but I was not aware…thanks for the post!
Thx a lot, those pesky OSX hidden files gone! (Also ._.DS_STORE 🙂 ) Cheers
You guys are great…a sincere thank you for an ex mac user 🙂
del /s /q /f /a:h ._* is the correct one for me (or without /a:h)
Your wild cards do not match the latest Mac OSx Yosemite garbage HEAP. Use this:
del /s /q /f /a:h *DS_STORE
del /s /q /f /a:h ._*
del /s /q /f *DS_STORE
del /s /q /f ._*
However, this does nothing to clean out zip or other compression archives.
Is there a way to prosecute scum polluting the universe?
These commands only work if the files are local. These folders like .AppleDouble, .Parent and .DS_STORE are hidden to Windows O.S. and can’t be seen with ATTRIB command. Once these folders are on a server they can’t be deleted by any method (Windows) I am aware of. I welcome any suggestion how to remove them. Thanks.
When typing in terminal under OSX or DOSprompt under Windows, things can go pretty much wrong very fast. Look the one above typing *.* instead of *_.* and deleting all his files.
Why don’t you guys just relax and use something like IXSOFT Folderwasher. Does the job nicely in OSX/Windows. No need of typing those DOS commands.
And on Apple’s HTFS drives you can kill the clutter of thumbs.db that Windows splatters across Mac drives…
Or ‘Dot Delete’ (Windows) or ‘DS_Store Cleaner’ or ‘DS_Store Remover’ (OSX)
Those OSX users really angry at DS_store may look to:
But this is not for the faint hearted.
Be remembered that living in a mixed enviroment of OSX/Windows, there is always what Apple tells about preventing OSX from writing DS_store to network shares:
Preventing the clutter from being produced may be better than cleaning it up daily.
However this does not apply for USB drives – see the interesting comments at death-to-ds_store. Use ‘Finder Cleaner’ on OSX.
And watch out using DOS del .DS_store commands on NTFS drives that have Mac-Install-files on them, like .dmg or .pks. Those may get corrupted and left unusable for the mac. Be sure to have just windooze stuff on them when hitting execute.
Those wanting to have .DS_Store files deleted automatically when ejecting USB-media from OSX may look to:
I want to use this to rid my server of ._* files. My Macs and PCs share a Drobo 5N NAS as a file server. Tired of seeing these ghost when I am on server with PC.
Found this with google and have a update for you:
You don’t have to run the del with /a:h and without
Just use /a (no :h) to match iles with all attributes
You can easily verify by
dir c: /a:h
dir c: /a
I love you. Genius.
[…] http://awesometoast.com/delete-all-instances-of-ds_store-in-windows/ […]
What command line would I use to delete the DS_Store files on an external hard drive? The ones in question are drive G: and drive F:. How would I write the command line for them?
Thanks a lot for this. Very helpful. At first it wasn’t working for me, was getting the “couldn’t find” error, but realized it was because I had a:h in there when the files weren’t hidden for me. Changing the “a:h” to just “a” made the difference.
**Steps I used in Windows 10**
1. Navigate to directory you want to use this in
2. Click address bar, COPY folder location (“C:\Users\yourname\Desktop\yourfolder” for example)
3. Open CMD
4. TYPE: cd
5. CMD should show that you’re now in folder
6. PASTE “del /s /q /f /a ._*”
7. List of deleted files should appear.
Thanks, you saved the day!
Thank you so much. This really helped.
This command works great
del /s /q /f /a ._*
great post, thanks so much — longtime mac user going back to windows. the above comments helped most. i’m a novice at most of this stuff so let me reiterate how i did it:
1) open command prompt
2) type “DRIVE:” (C:, D:, whatever)
3) copy location of folder with the unnecessary files
4) type “cd” in command prompt and paste the folder location
5) afterward, continue with the commands. “del /s /q /f /a .DS_STORE” first and then, as mentioned in the previous comment, i’ve found “del /s /q /f /a ._*” works best
Thanks! Worked for me but only on disk C: …
To remove junk from any other drive or folder you can use portable “.bat” file:
– create .txt file anywhere with any name;
– open this file and paste there “del /s /q /f /a .DS_STORE” as usual text;
– close file with saving;
– change file extension from “.txt” to “.bat”;
– put this file in folder that you need to clean up;
– open (start) the .bat file.
it will remove all .DS_STORE files in this folder and in all subfolders.
“._.” will only target “._.DS_Store” files. If you’re running it on a drive that is unlikely to contain preference/configuration files, go ahead with targeting “._”
What about __MACOSX directories ? Done a lot of googling and cant find a simple way to recursively remove a specific directory name in windwos ?
I found out how to do it..
for /d /r %i in (__MACOSX*) do rmdir /s /q “%i”
does the trick.. but recommended you do this version first to be sure its what your want !
for /d /r %i in (__MACOSX*) do @echo rmdir /s /q “%i”
Had to use the wildcard * after __MACOSX else it tries to do it on all files not dirs