IdeaHat
IdeaHat

Reputation: 7881

batch wildcards extending extension

So from Why does dir *.txt return *.txtf also? tells me that the reason my

del /S moc_*.cxx call is also deleting moc_foo.cxx_parameters

If I do not know the length of foo, is there any way in windows to delete only the .cxx files?

EDIT I have found an "equivalent" call is

forfiles /S /m *.cxx /c "cmd /c del @file"

And to do it quietly if the file is not found

forfiles /S /m *.cxx /c "cmd /c del @file" 2> nul

What a terrible design!

Upvotes: 0

Views: 782

Answers (1)

Magoo
Magoo

Reputation: 80203

for %i in (moc_*.cxx) do if /i "%~xi"==".cxx" ECHO del "%i"

should select only .cxx files for deletion. Remove the echo keyword to execute the deletion after verification. Change % to %% throughout to use within a batch file.

Upvotes: 2

Related Questions