Delete Specific File Size using CMD prompt

zaldhie

She Hates Me
Local time
9:45 AM
Messages
21
Location
Abu Dhabi
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!


QLutfqQ.png
 

My Computer

Computer type
PC/Desktop
Computer Manufacturer/Model Number
DELL
OS
Windows 7 Professional 64-bit SP1
CPU
Intel(R) Core(TM) i3-2100 CPU @ 3.10GHz
Motherboard
Dell Inc
Memory
24GB Dual-Channel DDR3 @ 665MHz (9-9-9-24)
Graphics Card(s)
NVIDIA GeForce GT 730 ZOTAC 4GB RAM
Sound Card
Realtek High Definition Audio
Monitor(s) Displays
HP S2031 19 inch 60Hz
Screen Resolution
1600x900 pixels
Hard Drives
ST3500413AS ATA Device 500 GB
WDC WD20EZRX-00D8PB0 ATA Device 2TB
PSU
TwinMOS
Case
DELL Optiplex 790
Keyboard
DELL USB Keyboard
Mouse
DELL USB Mouse
Internet Speed
100 Mbps
Antivirus
Webroot Anti Virus
Browser
Mozilla Firefox 42.0
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 "[DEL]Size on disk[/DEL]")
    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.
 

Attachments

  • Delete_Size.bat
    Delete_Size.bat
    115 bytes · Views: 23
  • Size.PNG
    Size.PNG
    1.5 KB · Views: 26
  • Del.PNG
    Del.PNG
    4.9 KB · Views: 27
Last edited:

My Computer

Computer type
Laptop
Computer Manufacturer/Model Number
HP EliteBook 8530w Mobile Workstation
OS
Windows 7 Ultimate x64 (XP, 98SE, 95, 3.11, DOS 7.10 on VM) + Ubuntu 10.04 LTS Lucid Lynx
CPU
Intel Core 2 Duo Processor P8600 (2.40 GHz, 3 MB L2 cache)
Motherboard
Mobile Intel PM45 Express Chipset ICH9M-Enhanced
Memory
4GB 800 MHz DDR2 SDRAM
Graphics Card(s)
ATI Mobility FireGL V5700 with 256 MB
Sound Card
SoundMAX Integrated Digital HD Audio
Monitor(s) Displays
15.4-inch WXGA anti-glare (1280 x 800 resolution)
Screen Resolution
1280 x 800
Hard Drives
500GB + 1TB
Mouse
Synaptics PS/2 Port Touchpad, USB Mouse
Internet Speed
4 Mbps
Antivirus
MSE
Browser
Firefox, Chrome, IE
Other Info
Authentec AES2810 Fingerprint Reader
Back
Top