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
zaldhie

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
gladson1976

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.

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, 2 views)
My System SpecsSystem Spec
Reply

 Delete Specific File Size using CMD prompt




Thread Tools Search this Thread
Search this Thread:

Advanced Search




Similar help and support threads
Thread Forum
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...
Software
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...
Tutorials
HDD big size file, help to delete
From the List, Which are can be safely to delete?
Performance & Maintenance
Multiple pdf printing at specific size.
I have multiple pdf files which I wish to print as A3. Is there a fast way to do this or do I have to open them and manually and click print for each one?
General Discussion
Laptop restricted to specific SSD size
I 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...
Hardware & Devices
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.
Customization


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 04:17.

Twitter Facebook Google+



Windows 7 Forums

Seven Forums Android App Seven Forums IOS App