如何搜索大于特定大小的文件并对其执行某些操作?

时间:2023-01-15 09:45:52

I would like to search for files in my different drives that have a size lower than 800Ko and to launch an MD5 checksum of them (with Microsoft tool FCIV).

我想在我的不同驱动器中搜索大小低于800Ko的文件,并启动它们的MD5校验和(使用Microsoft工具FCIV)。

I think it can be done using the dir command but I am not sure to know how can I check for the filesize (lower than 800Ko) and then being able to retrieve the full path of each file and add it as an argument to the FCIV command.

我认为可以使用dir命令完成,但我不知道如何检查文件大小(低于800Ko)然后能够检索每个文件的完整路径并将其作为参数添加到FCIV命令。

EDIT: I use this code but actually the proces never ends because it is stucks on directory where I have "access denied". It is possible to skip those directories ?

编辑:我使用此代码,但实际上进程永远不会结束,因为它卡在我有“访问被拒绝”的目录上。可以跳过这些目录吗?

@echo off
setLocal EnableDelayedExpansion
REM for /f "tokens=* delims= " %%a in ('dir /A HS /s /b c:\') do (
for /f "tokens=* delims= " %%a in ('dir c:\ /s /b /A-d') do (
if /I %%~Za LEQ 600000 (
echo %%~Za
fciv -md5 "%%~a" -xml DatabaseMD5.xml  
                            )
                                                                )

@pause

Thank you

1 个解决方案

#1


Wow, you want to do this to every file on the drive? Anyhow, here's a few tweaks to what you have so far.

哇,你想对驱动器上的每个文件执行此操作吗?无论如何,这里有一些调整到目前为止你所拥有的。

@echo off
rem   setLocal EnableDelayedExpansion
for /R c:\ %%a in (*) do (
    if %%~za GTR 0 if %%~za LSS 800000 (
        echo "%%a" %%~za
        fciv -md5 "%%a" -xml DatabaseMD5.xml 
    )
)

pause

#1


Wow, you want to do this to every file on the drive? Anyhow, here's a few tweaks to what you have so far.

哇,你想对驱动器上的每个文件执行此操作吗?无论如何,这里有一些调整到目前为止你所拥有的。

@echo off
rem   setLocal EnableDelayedExpansion
for /R c:\ %%a in (*) do (
    if %%~za GTR 0 if %%~za LSS 800000 (
        echo "%%a" %%~za
        fciv -md5 "%%a" -xml DatabaseMD5.xml 
    )
)

pause