How to Use PowerShell to Delete All .DS_Store Files in the Current and Subdirectories on Windows11

🕘
⏱️
👁️ * VIews

Open PowerShell in the Current Directory

Hold down the Shift key and right-click on a blank area within the File Explorer window of your target folder. Then select “Open in Terminal” from the context menu. This will open a PowerShell window already pointed to the current directory.

Open PowerShell in Current Directory

Run the Following PowerShell Command

Press Enter to execute the command. It will search for and delete all .DS_Store files recursively.

1
Get-ChildItem -Path . -Include .DS_Store -Recurse -Force | Remove-Item -Force

If You’re Using Command Prompt (CMD)

If you’re using CMD instead of PowerShell, you can use the following command:

⚠️ Make sure you are already in the correct target directory before running this command.

1
for /r . %a in (.DS_Store) do del /s /q "%a"

Reprinted from: Yijile.com( https://yijile.com/en/how-use-windows11-powershell-terminal-commands-delete-all-ds_store-files/ )

CC BY-NC-SA 4.0 Statement
Licensed under CC BY-NC-SA 4.0 .
Please credit the source and link to this article, indicate if changes were made, and share under the same non-commercial terms.

Last updated on |
一极乐 赏荷