@echo off setlocal enabledelayedexpansion

set "search_folder=%1" set "output_file=%2"

if not defined search_folder ( echo Usage: find_duplicates.bat [search_folder] [output_file] exit /b )

if not defined output_file ( echo Usage: find_duplicates.bat [search_folder] [output_file] exit /b )

if not exist "%search_folder%" ( echo Error: %search_folder% does not exist. exit /b )

echo Searching for duplicates in %search_folder%... set "dup_count=0" set "dup_list="

for /r "%search_folder%" %%f in (*) do ( set "hash=" for /f "tokens=1,2" %%a in ('certutil -hashfile "%%f" MD5 ^| findstr /i /v "md5"') do ( set "hash=%%b" ) if defined hash ( if not defined file_list[!hash!] ( set "file_list[!hash!]=%%f" ) else ( set "dup_count=!dup_count!+1" set "dup_list=!dup_list! !file_list[!hash!]! %%f" ) ) )

echo Found %dup_count% duplicates. if %dup_count% gtr 0 ( echo Writing duplicate list to %output_file%... echo %dup_list% > %output_file% )

echo Done.

生成一段查找内容相同文件的win10批处理bat文件

原文地址: https://www.cveoy.top/t/topic/bFLS 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录