In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
Editor to share with you how to use bat to get the file size, I believe most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to know it!
Let's start with a simple sentence code:
For / f% I in ('dir / b c:\ 450010.jpg') do echo% ~ zi
Complete judgment code:
The code is as follows:
@ echo off
:: copy the following home page every 5 minutes
For / f% I in ('dir / b c:\ index2.htm') do (
Set indexdx=%%~zi
)
If% indexdx% gtr 5120 (
Echo y | xcopy c:\ index2.htm / d / r / k c:\ index.htm
)
Pause
Determine the file size under dos
I'm afraid it won't work under pure dos, but bat under window is just so-so, when c:\ 1.txt is greater than 3.999G. Check every about 20 seconds.
The code is as follows:
@ echo off&setlocal Enabledelayedexpansion
Set Runner:\ 1.txt
: 1
Ping-n 20 127.0 > nul
For / f "tokens=1-3 delims="% an in ('dir "% R%" ^ | find / I "1 file"') do (
Set QQ% c
Set / a Qizhuangqizhuo!
If! Q! Lss 2048start "1.exe"
)
Goto 1
The Dos script determines the file size
The code is as follows:
@ echo off & setlocal EnableDelayedExpansion
Del 1.txt / q
Del 2.txt / q
For% I in (*) do (echo% ~ fzi > > 1.txt) rem stores the file size to 1.txt
For / f "tokens=1* delims=" an in (1.txt) do (
Set "zer=%%a"
Set "pat=%%b"
If! zer! Gtr 5120 (
If not "! pat:~0,-1!" = = "% ~ 0" echo "! pat:~0,-1!" & echo "! pat!" > > 2.txt rem put file names greater than 5KB into 2.txt
)
)
Echo "done."
[remarks] judgment sentences commonly used in if
1. If exist d:\ test.txt (test.txt exists under echo D) else (test.txt does not exist under echo D)
2. If "abc" = = "xyz" (echo string abc equals string xyz) else (echo string abc is not equal to string xyz)
3. If 1 equ 2 (echo 1 equals 2) else (echo 1 is not equal to 2)
4. If defined str (the echo variable str has been assigned to% str%) else (the value of the echo variable str is empty)
Chinese meaning relation symbol English interpretation
Equal to equ equal
Greater than gtr greater than
Greater than or equal to geq greater than or equal
Less than lss less than
Less than or equal to leq less than or equal
Not equal to neq no equal
The above is all the contents of the article "how to use bat to get file size". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.