Welcome to Windows 7 Forums. Our forum is dedicated to helping you find support and solutions for any problems regarding your Windows 7 PC be it Dell, HP, Acer, Asus or a custom build. We also provide an extensive Windows 7 tutorial section that covers a wide range of tips and tricks.

Windows 7: Delete Specific File Size using CMD prompt

Hi just want to ask a small favor if there's a way i can delete certain files using command prompt base on their file size. i uploaded the screenshot of the file that i know it's a virus and they have the same size 798kb. it is possible to delete this file using command prompt?

I guess this is what you need. This code should be in a batch file (put the code in a text file with the extension as .bat) and run it. I've added comments for the code.

Code:

@echo off
rem Select all files recursively from the current folder
for /r %%x in (*.*) do (
rem Check if the file size is the one you want (this must be in bytes, take the "Size" from the file properties, not "Size on disk")
if %%~zx == 542208 (
rem Delete the file, if it matches the size you want to delete
del "%%x"
rem Show a message
@echo Deleted %%x, Size %%~zx
)
)

Hope this is what you want. I have also attached the batch script (make sure you change the size to what you want). Also if you want to delete files of a specific type, change the file filter (*.*) in the "for" statement.

File - Delete from Command PromptHow to Delete a File in Windows from the Command Prompt
This tutorial will show you how to permanently delete a File in Vista, Windows 7, or Windows 8 using the DEL or ERASE command from within a command prompt.
This can be handy if you cannot delete the file normally.While you can run...

Laptop restricted to specific SSD sizeI have a laptop (Core2Duo) at this stage it is four years old, I'd like to squeeze another two more years out of it, maybe 2.5. I was planning on doing the last upgrade I could for this laptop which is the HDD, currently has a 5400 (320 GB) it's a larger HDD, but slow. The manual states that the...