How do I use the command prompt to delete files with similar names?

Page 2 of 2 FirstFirst 12

  1. Posts : 1,621
    Windows 10 Home
       #11

    Hotsuma said:
    ...except for the ones that have the "[!]" at the end...
    That might be trickier than it looks; let a few others weigh in before doing mass deletes.
      My Computer


  2. Posts : 31,674
    10 Home x64 (22H2) (10 Pro on 2nd pc)
       #12

    You need to use one or more wildcards that would match the ones you want to delete, but not match the one you want to keep like this (make sure there'a space between the two wildcards): del *[b*.gb *[t*.gb

    Just to be sure, you could first give all your [!] files the read-only attribute with attrib *[!].* +R
    You can make them read-write again later with attrib *[!].* -R

    Code:
     Directory of C:\TEMP\TEST
    07/03/2017  20:34    <DIR>          .
    07/03/2017  20:34    <DIR>          ..
    07/03/2017  20:34                 7 Amazing Spider-Man, The (UE) [b2].gb
    07/03/2017  20:34                 7 Amazing Spider-Man, The (UE) [b3].gb
    07/03/2017  20:34                 7 Amazing Spider-Man, The (UE) [!].gb
    07/03/2017  20:34                 7 Amazing Spider-Man, The (UE) [b1].gb
    07/03/2017  20:34                 7 Amazing Spider-Man, The (UE) [b4].gb
    07/03/2017  20:34                 7 Amazing Spider-Man, The (UE) [b5].gb
    07/03/2017  20:34                 7 Amazing Spider-Man, The (UE) [T+Fre_Emulation-151].gb
    07/03/2017  20:34                 7 Amazing Spider-Man, The (UE) [T+Ger0.99_Star-trans].gb
    07/03/2017  20:34               452 TEST.bat
                   9 File(s)            508 bytes
                   2 Dir(s)  181,137,719,296 bytes free
    C:\TEMP\TEST>del *[b*.gb *[t*.gb
    C:\TEMP\TEST>dir
     Volume in drive C is WINDOWS
     Volume Serial Number is 3440-777B
     Directory of C:\TEMP\TEST
    07/03/2017  20:36    <DIR>          .
    07/03/2017  20:36    <DIR>          ..
    07/03/2017  20:34                 7 Amazing Spider-Man, The (UE) [!].gb
    07/03/2017  20:34               452 TEST.bat
                   2 File(s)            459 bytes
                   2 Dir(s)  181,137,735,680 bytes free
      My Computers


 

  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 15:07.
Find Us




Windows 10 Forums