Action completed
Windows × macOS Cross-Platform Front-End Engineering Memo >20,000 Copies Celebration

Batch Deleting OS X .DS_Store Files on Windows

When designers bundle image assets on high-end Mac Pros and ship them to developers on traditional Windows PCs, unzipping the archive unleashes a hidden .DS_Store file in every single subfolder. Explore this interactive guide to learn the fastest native Windows shortcut, automated recursive Node.js scripts, one-click batch wrappers, and vote in the community book giveaway raffle.

Originally authored by Zhang Xinxu (Author of The World of CSS). Interactive educational demo edition.

1 The Zero-Code Native Windows Explorer Method

Thanks to reader comments, the officially crowned "best and fastest" way requires zero programming. Open the root folder in Windows Explorer, search for .DS_Store, press Ctrl + A to select all nested occurrences, and hit Delete. Peace and quiet restored instantly.

Code:
Explorer-Shortcut.cmd
:: 1. Open target root folder in Windows File Explorer
:: 2. Type `.DS_Store` into the top-right search box (Ctrl + F)
Search: .DS_Store

:: 3. Select all found files across all subfolders
Action: Select All (Ctrl + A)

:: 4. Permanently remove the clutter
Action: Delete (Shift + Delete)
:: Result: Peace and quiet restored across dozens of subdirectories.
Result: Live Explorer Search Showcase
This PC > Local Disk (D:) > Designer_Export_Assets
Name Folder Path Type Size
8 items 0 items selected

2 Recursive Node.js Cleaner Script (no-ds.js)

When dealing with nested directory trees containing dozens of subfolders, a quick ten-minute script written with basic Node.js knowledge can crawl the directory tree via fs.readdir and fs.stat, recursively purging every .DS_Store file in milliseconds.

Code:
no-ds.js
const fs = require('fs');
stat = fs.stat;
const path = require('path');
/**
 * Method to delete .DS_Store files within a directory
 * @param  String dir Folder name / path
 */
let nods = function (dir) {
    fs.readdir(dir, function(err, files) {
        files.forEach(function(filename) {
            var src = path.join(dir, filename);
            stat(src, function (err, st) {
                if (err) { throw err; }
                // Check if it is a file
                if (st.isFile()) {
                    if (/\.DS_Store$/.test(filename)) {
                        fs.unlink(src, (err) => {
                          if (err) throw err;
                          console.log('Successfully deleted ' + src);
                        });
                    }
                } else {
                    // Treat as a directory
                    nods(src);
                }
            });
        });
    });
};

nods('./');
Result: In-Browser Virtual Directory & Node Runtime Simulation
PROJECT DIRECTORY TREE 4 .DS_Store files
Command Prompt - node no-ds Node.js v18.16.0
Microsoft Windows [Version 10.0.19045]
(c) Microsoft Corporation. All rights reserved.
 
C:\project_assets> _
Watches ./ recursively

3 Non-Coder Friendly Automation (run.bat & CLI One-Liner)

Non-coders shouldn't need to open terminal prompts. By packaging no-ds.js with a run.bat file, users can double-click to execute the cleanup. Furthermore, Windows CMD enthusiasts can achieve the same recursive result with a single native del /s /q /f /a:h .DS_Store command.

Code:
run.bat & Windows CMD One-Liner
:: Option A: Wrapper script inside `no_DS.zip` for double-clicking
@echo off
echo Purging all .DS_Store files via Node.js...
node no-ds.js
echo Successfully finished! World peace restored.
pause

:: Option B: Pure Windows CLI One-Liner (Zero Node.js dependency)
:: /s = recursive, /q = quiet, /f = force delete, /a:h = hidden files
del /s /q /f /a:h .DS_Store 2>nul
del /s /q /f .DS_Store 2>nul
Result: Interactive Batch & CMD Execution Runner
run.bat

Double-click or press button to trigger the execution.

Command Prompt - Windows 11 cmd.exe
Microsoft Windows [Version 10.0.22621.1702]
(c) Microsoft Corporation. All rights reserved.
 
C:\Users\Developer\Downloads\no_DS> _

4 Reader Celebration: "The World of CSS" 20,000 Copies Giveaway

At the conclusion of the article, the author celebrates The World of CSS surpassing 20,000 shipped copies in under 6 months! To give back to the community with prizes under 100 RMB, here is the interactive giveaway poll engine and budget calculator.

Code:
raffle-poll.js
// Prize candidates under budget limit (<= 100 RMB)
const MAX_BUDGET = 100;
const prizes = [
  { id: 'book', name: 'Signed "The World of CSS" Book', cost: 69, votes: 142 },
  { id: 'shirt', name: '"The World of CSS" Custom T-Shirt', cost: 69, votes: 98 },
  { id: 'husky', name: 'Husky Penguin Plush Toy', cost: 60, votes: 85 },
  { id: 'notebook', name: 'Qidian "Dian-niang" Notebook', cost: 49, votes: 53 },
  { id: 'qcoins', name: 'Q-Coins Pack (50 Q-Coins)', cost: 50, votes: 34 }
];

function voteForPrize(prizeId) {
  const item = prizes.find(p => p.id === prizeId);
  if (!item || item.cost > MAX_BUDGET) {
    throw new Error('Prize exceeds 100 RMB budget limit!');
  }
  item.votes++;
  return { item: item.name, newTally: item.votes };
}
Result: Interactive Voting Poll & Lucky Draw Simulator
🎉 Congratulations! Winner drawn for: Signed "The World of CSS" Book!