Can't find empty folders using Windows Explorer search function

Page 2 of 2 FirstFirst 12

  1. Posts : 989
    Microsoft Windows 10 Home
       #11

    Try3 said:
    No, they are just standard shortcuts - they have no attributes set but I also tried with their A bits on although I couldn't see any logic to doing so.
    Weird. When you run this command, what count value is displayed for the problem folders?
    Code:
    gci -recurse -Directory | ?{(gci $_.Fullname -force).count -eq 0} | select @{N = 'gciCount'; E = {(gci $_.Fullname -force).count}}, FullName | out-gridview
      My Computer


  2. Posts : 16,931
    Windows 10 Home x64 Version 22H2 Build 19045.4170
       #12

    Keith,

    The folder was called Repair-Volume [ChkDsk]. After I renamed it Repair-Volume ChkDsk I had correct results.
    - To confirm the cause I created another folder with [] in its name and the same thing happened until I removed the [].
    - PS cannot accept even a CD command to a folder with [] in its name.

    So the problem is solved and I've learnt not to include any symbols in folder names if I want to use PS processing.

    This lesson has been valuable so thank you.

    Denis
      My Computer


  3. Posts : 989
    Microsoft Windows 10 Home
       #13

    Thank you. I just learned something too!
      My Computer


  4. Posts : 16,931
    Windows 10 Home x64 Version 22H2 Build 19045.4170
       #14

    Keith,

    And while it had the [] in its name it was count value 0, which makes sense.

    I probably have countless folders-files with [] in their names. I have always been able to process them correctly in batch files, vbs & VBA. I'll have to work through a recursive batch file to find them & rename them.

    I never use certain symbols, for example &, in folder-file names because they can trip me up in batch file processing even if I think I have provided for them**. But [] have never been a problem before.

    {** For instance, using set "SomeVar=this&that" allows many common symbols to get processed without causing problems.}

    Denis
      My Computer


  5. Posts : 989
    Microsoft Windows 10 Home
       #15

    I think this is a case where using the -LiteralPath paramater (as opposed to default -Path) will give you correct results:

    Code:
    gci -recurse -Directory | ?{(gci -LiteralPath $_.Fullname -force).count -eq 0} | select @{N = 'gciCount'; E = {(gci -LiteralPath $_.Fullname -force).count}}, FullName | out-gridview
      My Computer


  6. Posts : 16,931
    Windows 10 Home x64 Version 22H2 Build 19045.4170
       #16

    Keith,

    You are correct. And I've used -LiteralPath before but had forgotten its significance. I must get around to opening my PS for idiots book and study it properly instead of just stumbling my way through only when I cannot put together a batch file / vbs / VBA solution for something.

    Denis
      My Computer


 

  Related Discussions
Our Sites
Site Links
About Us
Windows 10 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 10" and related materials are trademarks of Microsoft Corp.

© Designer Media Ltd
All times are GMT -5. The time now is 21:59.
Find Us




Windows 10 Forums