Skip to content

Instantly share code, notes, and snippets.

@ph33nx
Created February 11, 2024 19:58
Show Gist options
  • Save ph33nx/39d44deff36fbff54812030cf3194b5a to your computer and use it in GitHub Desktop.
Save ph33nx/39d44deff36fbff54812030cf3194b5a to your computer and use it in GitHub Desktop.
Delete hidden MacOS files on Windows using Powershell Script
# 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