Created
February 11, 2024 19:58
-
-
Save ph33nx/39d44deff36fbff54812030cf3194b5a to your computer and use it in GitHub Desktop.
Delete hidden MacOS files on Windows using Powershell Script
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Get the current directory | |
$folder = Get-Location | |
# Delete hidden files recursively based on pattern | |
Get-ChildItem -Path $folder -Recurse -Force -File | Where-Object { $_.Name -like "._*" } | ForEach-Object { | |
# Remove any file attributes | |
Set-ItemProperty -Path $_.FullName -Name Attributes -Value 0 | |
# Attempt to delete the file | |
Remove-Item -Path $_.FullName -Force | |
} | |
Write-Host "All hidden files starting with '._' deleted recursively." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment