2 answers
Hello computer,
I've done quite a bit of searching and found this:
call :size_file file_to_check.txt
if %size%==0 echo file empty>>log_file.txt
:size_file
set size=%~z1
goto exit
:exit
The call lets you invoke the size_file function by passing it the file to check as a parameter. Your script then pauses and looks for the function :size_file. With the set function, you assign the value of your file size to the variable size (for reference, if you right-click on your file and then properties, the size returned is the one written next to size and not size on disk). The variable %~z1 corresponds to the size of your file. Then the goto exit allows you to exit the function. Your script then resumes where it left off, that is at the IF level. There, you test your value and display your message. Here, I display it in a log file.
There you go.
I've done quite a bit of searching and found this:
call :size_file file_to_check.txt
if %size%==0 echo file empty>>log_file.txt
:size_file
set size=%~z1
goto exit
:exit
The call lets you invoke the size_file function by passing it the file to check as a parameter. Your script then pauses and looks for the function :size_file. With the set function, you assign the value of your file size to the variable size (for reference, if you right-click on your file and then properties, the size returned is the one written next to size and not size on disk). The variable %~z1 corresponds to the size of your file. Then the goto exit allows you to exit the function. Your script then resumes where it left off, that is at the IF level. There, you test your value and display your message. Here, I display it in a log file.
There you go.
do you know the command to do the same thing but on a complete folder?
Example:
if c:/folder is greater than 2 bytes, execute the command
thank you in advance