0

I'm trying to delete all files with a specific extension in a folder. I found this question on how to get all txt files and I thought about using that to get all files by extension and removing them, but I'm not sure how to do that.

idleberg
  • 12,634
  • 7
  • 43
  • 70
Gianmarco
  • 792
  • 2
  • 14
  • 38

1 Answers1

1

There is no difference between listing and deleting files:

FindFirst $0 $1 "$INSTDIR\*.txt"
loop:
  StrCmp $1 "" done
  StrCpy $2 "$INSTDIR\$1"
  IfFileExists "$2\*.*" +2 ; A directory?
    Delete "$2"
  FindNext $0 $1
  Goto loop
done:
FindClose $0

That being said, the documentation says wildcards are supported so you should be able to just do

Delete "$INSTDIR\*.txt"
Anders
  • 97,548
  • 12
  • 110
  • 164