locked
How Do I Search For Items That Do Not Contain an Underscore in File Explorer RRS feed

  • Question

  • Hi,

    Im trying to clear out a folder of various items. I want to remove all files without an underscore in their filename. Is there any easy way for me to search for all items without an underscore in them? So far I have tried using -"*_" and NOT"*_" as well as both of those without the asterisk. Any help would be greatly appreciated.

    Thank you

    Wednesday, October 28, 2020 7:42 PM

All replies

  • Hi,

    This is definitely easier with PowerShell, you can try the followng PowerShell script:

    $SpecialChar = [char]0x005F
    Get-ChildItem -File -Recurse | Where-Object {!$_.Name.Contains($SpecialChar)} | Remove-Item

    The [char]0x005F is the Unicode Binary for underscore "_" 
    https://unicodemap.org/search.asp?search=_

    Make sure you test it on a test folder first!

    Best regards,
    Leon


    Blog: https://thesystemcenterblog.com LinkedIn:



    • Edited by Leon Laude Wednesday, October 28, 2020 8:36 PM
    Wednesday, October 28, 2020 8:34 PM