Last active
May 16, 2023 15:10
-
-
Save haltcase/0b2f0e1bdf7bbd09a1b488395d8c7023 to your computer and use it in GitHub Desktop.
Find & delete leftover "dot underscore" files from macOS, using PowerShell on Windows.
This file contains 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
# log the -WhatIf output to a file for review | |
start-transcript c:\mac-file-cleanup.txt | |
get-childitem -directory | | |
get-childitem -filter ._* -file -force -recurse | | |
# filter out the items that don't have an accompanying non-dot-underscore file | |
where-object { test-path -literalPath (join-path $_.directoryName ($_.name -replace '^\._','')) } | | |
foreach-object { remove-item -literalPath $_.fullName -force -WhatIf } | |
stop-transcript |
This file contains 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-childitem -directory | | |
get-childitem -filter ._* -file -force -recurse | | |
# filter out the items that don't have an accompanying non-dot-underscore file | |
where-object { test-path -literalPath (join-path $_.directoryName ($_.name -replace '^\._','')) } | | |
foreach-object { remove-item -literalPath $_.fullName -force } | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment