Delete files using cmd


  1. Posts : 37
    Windows 10 X64
       #1

    Delete files using cmd


    Hello, I want to search and delete files, in a folder by file extension
    ie: all files with extension jpeg, in a folder and it's subfolders ie: D:\New
    Can someone please write me a script to do that?
    Regards
      My Computer


  2. Posts : 42,963
    Win 10 Pro (22H2) (2nd PC is 22H2)
       #2

    Hi, why not use Windows search to help you do that?

    Open the top folder in file explorer.

    In the search box type
    *.jpeg
    <Return>

    You should see a list of all jpg files in the folder and its sub-folders.

    select one result, CTRL A (select all), delete.

    If you really wish to use a command prompt, a simple Google (e.g.) search ->
    Recursively Delete a Specific File Type from all Subfolders | SumTips
      My Computers


  3. Posts : 14,007
    Win10 Pro and Home, Win11 Pro and Home, Win7, Linux Mint
       #3

    There are the old DOS commands that still work but I use File Explorer and its Search by clicking the main/top folder containing the files and then click Search, put in the extension in question such as *.jpg [the asterisk is a wild card, eliminates using the name]. When the Search has completed I Select all those files and Delete. It works just the same as copying or moving the files of that type to another location.


    Sorry, Dalchina is a faster typist..
      My Computers


  4. Posts : 869
    Windows 10 Professional x64 21H2
       #4

    I use Everything When I need to search for particular files I need. It has much more flexibility of use and also shows the path for each file so you know its origin.
    Attached Thumbnails Attached Thumbnails Delete files using cmd-jpg.png  
      My Computers


  5. Posts : 456
    Windows 10
       #5

    Something like:

    del /s /q D:\New\*.jpeg
    del /s /q D:\New\*.jpg
      My Computer


  6. Posts : 1,807
    Windows 10 Pro 21H1 19043.1348
       #6

    I prefer to use Command Line for many functions, however; I would highly advise against it for performing bulk file deletions across multiple folders. If your brain is far sharper than most and you never ever make errors, maybe that works OK, maybe not.

    I would go with Lance1's recommendation of using Everything Search. It's lightening fast and will instantly produce a complete list, clearly displaying all of the file locations.

    A quick review of all these paths might help you suddenly realize, 'O ya, that's an important file I want to keep'.

    I like to triple check any bulk file operations, with using a Command Line solution, you never get to see all of the content you're deleting.

    As time passes , I would rather take a wee bit longer to be very confident of my actions than to save a trivial amount of time and potentially suffer the consequences of an impetuous choice.
      My Computer


  7. Posts : 42,963
    Win 10 Pro (22H2) (2nd PC is 22H2)
       #7

    Windows search is as fast if the folders are already indexed. Speed is then not an issue.

    Faster if you have to search for, download and install another tool and then use it..
      My Computers


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

    FileSeek, free or fee, is another very good utility.
      My Computer


  9. Posts : 1,807
    Windows 10 Pro 21H1 19043.1348
       #9

    dalchina said:
    Windows search is as fast if the folders are already indexed. Speed is then not an issue.

    Faster if you have to search for, download and install another tool and then use it..

    I use QTTabBar and always have multiple explorer windows open, my files are indexed but I rarely use the search function.
    Every time I have, I'm quickly reminded of how incredibly slow it is.

    I doubt Windows Explorer could even come close to the speed of Everything Search.

    I use Everything Search as a SOP for any advanced file searches.

    Even with the marginal download speeds on a wireless connection, the 1.5Mb file for Everything Search is only a blink.

    Try it out and compare it to Windows Explorer, I dare you.
      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 19:32.
Find Us




Windows 10 Forums