windows7系統上尋找大於指定大小的檔案

來源:互聯網
上載者:User

標籤:尋找指定大小檔案

@echo off 

setlocal enabledelayedexpansion 


if "%1" equ "/?" ( 

    goto helpinfo 


:///ensure the command have 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 ( 

    echo 目錄不存在 

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 檔案大小值為非數實值型別 

    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 (*) do ( 

    if %%~za gtr %size% echo %%~za %%a 

goto :eof 


:helpinfo 

echo. 

echo 擷取指定目錄下大於給定值的所有檔案 

echo. 

echo  %0 dir [SIZE_VALUE] 

echo  %0 /c [dir] 收集指定檔案夾下[不指定dir,預設目前的目錄]的資訊,包括:所有目錄數,所有檔案數 

echo     dir 要搜尋的目錄,如果目錄為磁碟機,必須指定為此格式:c:\或者d:\ 

ECHO     SIZE_VALUE 檔案大小臨界值,單位為k,其中1k = 1024byte,不指定預設尋找大於1M的檔案 

echo. 

exit /b 0


本文出自 “記不起從前杯酒” 部落格,請務必保留此出處http://9429042.blog.51cto.com/9419042/1793772

windows7系統上尋找大於指定大小的檔案

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.