Search code examples
windowspowershellpromptdelete-file

Delete recursively some file without certain extensions


I've some big folders with many subfolders and i need to delete all files that aren't image jpeg|tiff|bmp|png|eps|gif and keep only that files with these extensions.

I ask something with windows powershell or prompt


Solution

  • try this

    @echo off
    set ROOTDIR=E:\Testdel\
    for /f "delims=" %%F in ('dir %ROOTDIR% /s /b /a-d ^|findstr /vile ".jpeg .jpg .gif .png .tiff .bmp .eps .cdr .cpt .psd"') do del "%%F"