code8
code8

Reputation: 103

cmd command to delete not containing (non pdf files) from a folder

Hi I want to delete non pdf files from Temp folder using cmd "del" command.

So need to include non pdf part in to following cmd command.

cm /c del /Q c:\Temp

Upvotes: 1

Views: 219

Answers (1)

Stephan
Stephan

Reputation: 56180

cd /d c:\temp
for %%i in (*) do (
  if /i "%%~xi" neq ".pdf" ECHO del "%%i"
)

for every file: if the extension is not .pdf then delete it.

Remove the ECHO if the ouptut satisfies you.

Upvotes: 1

Related Questions