Find files larger than the specified size on the Windows7 system

Source: Internet
Author: User

@echo off

Setlocal enabledelayedexpansion


If "%1" equ "/?" (

Goto Helpinfo

)


:///ensure The command has the "Dir" parameter

If "%1" Equ "" (

Goto Helpinfo

)


:///if first parameter Is/c,collect info of the directories

If "%1" equ "/C" (

set/a dirnum=0

set/a filenum=0

set/a filesize0=0

set/a filesize1=0

For/r%2%%a in (.) Do (

set/a dirnum=!dirnum! + 1

)

For/r%2%%a in (*) do (

set/a filenum=!filenum! + 1

set/a filesize0=!filesize0! +%%~za

If!filesize0! GTR 99999999 (

set/a Filesize1=filesize1 + filesize0/1024

set/a filesize0=0

)

)


set/a Filesize1=filesize1 + filesize0/1024

echo All directories number% 2:!dirnum!

echo All files number% 2:!filenum!

echo All files size% 2:!filesize1! K


Exit/b 0

)


:///////////if first parameter is not "/C", Find files

If not exist%1 (

The echo directory does not exist

Exit/b 1

)


:///ensure the parameter [Size_value] is numerial number


If "%2" NEQ "" (

set/a temp = 1

set/a B =!temp! +%2


If!b! Equ 1 (

echo File size value is non-numeric type

Exit/b 1

) Else (

set/a standardsize =%2 * 1024

)

)

://////collect Current dir information




If "%2" equ "" (

Call:findfilegreaterthan%1 1048576

) Else (

Call:findfilegreaterthan%1%standardsize%

)

Goto:eof





: Findfilegreaterthan

:///get all file and file size, output to%temp%\fileandsize

set/a size =%2

For/r%1%%a in (*) does (

If%%~za gtr%size% echo%%~za%%a

)

Goto:eof


: Helpinfo

Echo.

Echo gets all files that are larger than the given value in the specified directory

Echo.

echo%0 dir [Size_value]

Echo%0/c [dir] collects information from the specified folder [do not specify DIR, default current directory], including: All directories, all files

echo dir the directory to search for if the directory is a drive, you must specify this format: \ C or D:\

ECHO size_value File size threshold, in K, where 1k = 1024byte, does not specify a file with a default lookup greater than 1M

Echo.

Exit/b 0


This article is from the "can't remember the former Cup of Wine" blog, please be sure to keep this source http://9429042.blog.51cto.com/9419042/1793772

Find files larger than the specified size on the Windows7 system

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.