Avatar of SavindraSingh
Flag for India asked on

Script to locate PDF's files from computer and delete them


I am looking at a script which can auto locate PDF's files from computer and delete them .
PDF files are located on my documents, desktop and some time on C drive.  

Thank Nammi.
File Sharing SoftwareVulnerabilitiesEncryption

Avatar of undefined
Last Comment

8/22/2022 - Mon

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question

If you can use powershell you may try this inline

get-childitem DRIVE: -r | ? {$_.extension -eq ".pdf"} | foreach {remove-item -force $_.FullName}

Open in new window

Just change "DRIVE" to you drive letter.
This command will delete ALL pdfs on you drive to wich it will get access.

If you want to use cmd then this could work for you

for /f "tokens=*" %a in ('where /r DIRVE:\ *.pdf') Do del /q /f %a

Open in new window


You might want to run
C:\>dir *.pdf /s
first and see just what you'll be deleting... I came up with over 4GB of PDFs, with many of them being documentation in C:\Program Files\* and C:\Program Files (x86)\* folders.

Thanks for all, I like all the answers.
This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.