批处理脚本找到在Windows XP在D盘大于10MB的文件 [英] Batch script to find files greater than 10MB in D drive in windows xp

查看:1000
本文介绍了批处理脚本找到在Windows XP在D盘大于10MB的文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想有一个批处理脚本在哪里可以找到它们大于10MB在D档:驱动器

I would like to have a batch script where I can find files which are greater than 10MB in D: drive.

问候,
轨道。

Regards, Orbit.

推荐答案

下面是一个批处理脚本,将列出一个给定的目录是比一个给定的大小(以字节),所有文件和所有子目录:

Here is a batch script that will list all files that are greater than a given size (in bytes) in a given directory and all its subdirectories:

@echo off

setlocal enabledelayedexpansion

set "SEARCH_DIR=%~1"
set "FILE_SIZE=%~2"

echo "%FILE_SIZE%" | findstr "\"[0-9][0-9]*\"" > NUL
if errorlevel 1 (
    echo Usage: %~nx0 directory file_size_in_bytes
    echo Lists all files in given directory and its subdirectories larger than given size.
    exit /b 1
)

if not exist "%SEARCH_DIR%" (
    echo "%SEARCH_DIR%" does not exist.
    exit /b 1
)

for /R "%SEARCH_DIR%" %%F in (*) do (
    if exist "%%F" if %%~zF GEQ %FILE_SIZE% echo %%F
)

脚本首先执行一些错误检查和不是通过在给定的目录中的所有文件递归迭代,打印这些文件的大小大于或等于给定大小。的路径

The script first performs some error checks and than recursively iterates through all the files in the given dir, printing the paths of those files whose size is greater or equal to the given size.

例如,要列出所有文件大于10MB的D:驱动器,调用脚本从命令提示符按以下方式:

For example, to list all files greater than 10MB in D: drive, invoke the script in the following way from the command prompt:

C:\>list_larger_than.bat D: 10000000

这篇关于批处理脚本找到在Windows XP在D盘大于10MB的文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆