21

Following command works fine with one type of files ,

forfiles -p "C:abc\del" -s -m *.exe -d -70 -c "cmd /c echo @path"

Is it possible filter through multiple file extensions? *.exe, *.dll, *.xyz?

Strelok
  • 50,229
  • 9
  • 102
  • 115
mini998
  • 511
  • 1
  • 5
  • 11

2 Answers2

18

Not as nice as I hoped for but this oneliner can help out. Notice however that you can't use * as a filter because the IN function starts selecting files in that case.

for %G in (.exe, .dll, .xyz) do forfiles -p "C:abc\del" -s -m *%G -d -70 -c "cmd /c echo @path"

Used this for reference.

rene
  • 41,474
  • 78
  • 114
  • 152
6

It's also possible to traverse the directory structure in a single pass and test each file extension with an IF.

forfiles -p c:\ -s  -c "cmd /c (if @ext==\"exe\" echo @path) & ( if @ext==\"dll\" echo @path) &  ( if @ext==\"xyz\" echo @path)"

Just remember to escape the inner quotes \"dll\" instead of "dll", because the whole command is in a single string.

Farsee
  • 457
  • 3
  • 7