Delete all files with exact extension

seems like an easy one, but more complicated than i thought…
i am looking for a way to delete all files with an exact extension from all folders on the HD.
for example, i want to delete all files with *.DOC, but NOT with *.docx.
the straightforward way (file delete, dos del /s *.doc etc.) delete BOTH *.DOC and *.DOCX.
i tried using del "*.doc" but it also deletes *.docx.
i can use cygwin etc. but that requires 3rd party tools, and i would like to avoid it, if possible.
any thoughts?

Hello smalul,

Please try the following relevance:

q: concatenation "%0d%0a" of ("del /q %22" & it & "%22") of pathnames of find files ("*.doc") of (it; descendant folders of it) of folders "d:\test"
A: del /q "d:\test\4.doc"%0d%0adel /q "d:\test\1\3.doc"%0d%0adel /q "d:\test\1\2\2.doc"%0d%0adel /q "d:\test\1\2\3\1.doc"

If it gets you what you need, then your action might look like this:

delete __appendfile

appendfile {concatenation "%0d%0a" of ("del /q %22" & it & "%22") of pathnames of find files ("*.doc") of (it; descendant folders of it) of folders "d:\test"}

delete delete_doc_files.cmd
move __appendfile delete_doc_files.cmd
waithidden cmd /c delete_doc_files.cmd

Regards,
Vitaliy

Hi Vitaliy,

thanks for the super-fast reply :slight_smile:
the QnA gave the desired results, ill test the action script and report back.

Thanks!

Hi,
tested and working, thank you very much!

1 Like