1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

WAD [Discrepancy] Have rmdir work like described in the docs

Discussion in 'Support' started by nickles, May 14, 2016.

  1. nickles

    Joined:
    Jun 24, 2008
    Messages:
    220
    Likes Received:
    0
    The docs for rmdir state:

    "File Selection
    Supports command dialog, extended wildcards, ranges, multiple file names, and include lists."


    Unfortunately wildcards (and maybe others) are not supported, so that e.g.

    rmdir /qs hsperfdata_*

    fails with

    TCC: (Sys) The directory name is invalid.
    "D:\temp\hsperfdata_*"
     
  2. vefatica

    Joined:
    May 20, 2008
    Messages:
    7,883
    Likes Received:
    29
    It's the "/s". See the help. It's dangerous enough by itself. I'm not surprised that it expects the name of a directory.

    It's easy enough to get around:

    Code:
    do dir in /a:d hsperfdata_* ( rmdir /qs %dir )
     
  3. vefatica

    Joined:
    May 20, 2008
    Messages:
    7,883
    Likes Received:
    29
    It sounds like you're cleaning %TEMP. Do you get directories with names like "de96df7b3a4f5ed2f1e9f6375e785c90", i.e., 32 hex characters?

    I do, and though I don't know who creates them, I know from experience that they can be deleted safely. It took a while, but I just cooked up this command which might be useful in a CLEANTEMP.BTM.
    Code:
    do dir in /p dir /a:d /b /ne ::"^[0-9a-fA-F]{32,32}$" ( rmdir /q /s %dir )
    Apparently, you can't give DO a regex file spec ... too bad.
     
  4. nickles

    Joined:
    Jun 24, 2008
    Messages:
    220
    Likes Received:
    0
    @vefatica

    I'd like to replace some of MSys's "rm -rf ..."s - which sadly are much slower than "del" (which is not the fault of "rm" but that of MSys). Using your method would require me to replace quite a lot of "rm -rf" commands with the above mentioned "do" command which seems quite a bit of overhead to me. And yes, it's possibly dangerous - but that's my problem ;-); btw. the ones of us still using the "good ol' command line" are surely aware of this...

    Anyway, either the docs are wrong, or the command.
     
  5. RogerB

    Joined:
    Apr 18, 2014
    Messages:
    142
    Likes Received:
    3
    Check the help for the /S option of rmdir, it explicitly states that it can't be used with wildcards.
     
  6. rconn

    rconn Administrator
    Staff Member

    Joined:
    May 14, 2008
    Messages:
    9,804
    Likes Received:
    82
    As Vince said, the docs are correct and RD does not support wildcards with /S. (IMHO that would be a disastrous combination.)
     
  7. JohnQSmith

    Joined:
    Jan 19, 2011
    Messages:
    564
    Likes Received:
    8
    Ran into the same thing today cleaning up a folder tree I was playing with. However, by changing the command slightly (from "*" (asterisk) to "." (dot)) it did an override of the wildcard limitation. It even prompted me with a wildcard...

    Code:
    [C:\test] $ dir
    
     Volume in drive C is unlabeled      Serial number is 262b:d729
     Directory of  C:\test\*
    
     9/20/2016  11:32         <DIR>    .
     9/20/2016  11:32         <DIR>    ..
     9/20/2016  11:33         <DIR>    dir1
     9/20/2016  11:33         <DIR>    dir2
     9/20/2016  11:34         <DIR>    dir3
                       0 bytes in 0 files and 5 dirs
          66,485,268,480 bytes free
    
    [C:\test] $ rd /s *
    TCC: (Sys) The directory name is invalid.
     "C:\test\*"
    
    [C:\test] $ rd /s .
    C:\test\* : Are you sure (Y/N)? Y
    
    [C:\test] $ dir
    
     Volume in drive C is unlabeled      Serial number is 262b:d729
     Directory of  C:\test\*
    
     9/23/2016   9:53         <DIR>    .
     9/23/2016   9:53         <DIR>    ..
                       0 bytes in 0 files and 2 dirs
          66,493,485,056 bytes free
    
     
  8. gentzel

    Joined:
    Sep 24, 2013
    Messages:
    21
    Likes Received:
    0
    Sounds right to me. "." is a directory name, not a wildcard.
     

Share This Page