I'm having a little troubles with my script in .bat. My task is to write a script that will check a file for a few things. I've already defined some of those things, but now I'm stuck. My problem is that I don't know how to define a condition that says: If the file is hidden or read-only, delete this attribute and write some info about the change to the file (some text).
And then I'm having a second problem and that is that the script has always to write something to the file, but when I try to write something to the file (while the script is running) and then I save it, there is always just the thing the script has to write in it. Would somebody please give me some advice? I'm a novice. Thanks a lot for all the responses.
here is the script itself:
@echo off
title file-checking script
set file="file.txt"
set maxbytesize=1
type NUL > file.txt
pause
:loop
if exist file.txt @echo ok> file.txt
if not exist file.txt type NUL > file.txt
FOR /F "usebackq" %%A IN ('%file%') DO set size=%%~zA
if %size% LSS %maxbytesize% (
echo.File is under %maxbytesize% byte
) ELSE (
del file.txt
)
timeout/t 2
goto loop