DOS下比较两个文件的大小
发布日期:2021-06-28 21:10:46 浏览次数:2 分类:技术文章

本文共 728 字,大约阅读时间需要 2 分钟。

首先建立一个批处理文件,命名为comparesize.bat.

@echo offrem 比较两个文件的大小,返回较大文件的编号,相同返回0.set file1=%1set file2=%2dir /-c %file1%>comparetemp1.txtdir /-c %file2%>comparetemp2.txtfindstr /c:"1 个文件" comparetemp1.txt>sizetemp1.txtfindstr /c:"1 个文件" comparetemp2.txt>sizetemp2.txtsetlocal EnableDelayedExpansionfor /f "tokens=3 delims= " %%i in (sizetemp1.txt) do (set /a size1=%%i)for /f "tokens=3 delims= " %%i in (sizetemp2.txt) do (set /a size2=%%i)del comparetemp1.txtdel comparetemp2.txtdel sizetemp1.txtdel sizetemp2.txtif !size1! gtr !size2! (exit /b 1) else if !size1! lss !size2! (exit /b 2) else (exit /b 0)
然后再建立一个批处理文件来调用它,把它命名为test.bat

@echo offcall comparesize.bat No1filepath No2filepathecho %errorlevel%pause
echo将会输出较大文件的编号,相同的时候输出0.

转载地址:https://blog.csdn.net/yangyangsnr/article/details/40147535 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!

上一篇:C# checklistbox控件用法总结(怎样得到多选的值,以及动态加载数据)
下一篇:如何使用VS2008 C++/CLI 来自动化操作Excel

发表评论

最新留言

网站不错 人气很旺了 加油
[***.192.178.218]2024年04月15日 07时07分32秒