How to delete all files from folder excluding all .txt

Share your macros, knowledge, solutions, services, ...
Post Reply
Petr
Posts: 106
Joined: Tue Oct 18, 2016 1:12 pm

How to delete all files from folder excluding all .txt

Post by Petr » Wed Nov 02, 2016 7:39 am

How to delete different files but leave some not deleted. Let say I have in a folder files with ext as ".ht2" and some other files will be ".ovl" and ".en" and ".txt". I want to delete all files except files with extension ".txt". We use <file_enum> command as shown in this example:

Code: Select all

<cmds>

<#> Set here what folder you delete files from:
<varset>("vFolder=C:\Temp\filesToDelete","")

<#> Set here what file types you do not want to delete:
<varset>("vDoNotDelete=.txt","")

<file_enum>("%vFolder%\*",2,vFiles,vFilesNum)

<for>("i=0","i<%vFilesNum%","1")

   <if>("vFiles~=%vDoNotDelete%")
      <#> Do not delete this file
   <else>
      <filedel>("%vFolder%\%vFiles%",0,0,,,,"",1)
   <endif>

<for_end>

Post Reply