Link to home
Start Free TrialLog in
Avatar of SavindraSingh
SavindraSinghFlag for India

asked on

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

Team,

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.
ASKER CERTIFIED SOLUTION
Avatar of X-treem
X-treem
Flag of Belgium image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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

Avatar of Darr247
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.
Avatar of SavindraSingh

ASKER

Thanks for all, I like all the answers.