Windows 7 Forums
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

14 Mar 2016   #1

Windows 7 Professional 64-bit SP1
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?

thanks and advance guys!

My System SpecsSystem Spec
15 Mar 2016   #2

Windows 7 Ultimate x64 (XP, 98SE, 95, 3.11, DOS 7.10 on VM) + Ubuntu 10.04 LTS Lucid Lynx

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.

@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.

Attached Images
Delete Specific File Size using CMD prompt-size.png Delete Specific File Size using CMD prompt-del.png 
Attached Files
File Type: bat Delete_Size.bat (115 Bytes, 7 views)
My System SpecsSystem Spec

 Delete Specific File Size using CMD prompt

Thread Tools

Similar help and support threads
Thread Forum
Disable UAC prompt for specific application
Hi all , I have this program that will prompt for admin account whenever it launches , but strangely , it doesn't prompt for admin account for other users , it is only happening to me . Seems like a user profile issue , but if do not wish to recreate the user profile , how can I go about...
General Discussion
File permissions, can't delete file with 0 bytes size
I downloaded a file, didn't download correctly, size = 0 bytes. Reports owner unknown. I can't change ownership, remove file properties, any of that stuff. Can't rename or delete. I'm logged in as administrator but it keeps asking for administrator permission. ?? Another question about...
File - Delete from Command Prompt
How 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...
HDD big size file, help to delete
From the List, Which are can be safely to delete?
Performance & Maintenance
change taskbar icon size to specific size other than small or large?
Hi to all. Can we change taskbar icons' size to a specific size other than two default windows defined sizes? Tnx.

Our Sites

Site Links

About Us

Find Us

Windows 7 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 7" and related materials are trademarks of Microsoft Corp.

Designer Media Ltd

All times are GMT -5. The time now is 23:22.
Twitter Facebook Google+