DOS CMD Help
#1
Scooby Regular
Thread Starter
DOS CMD Help
I have a .bat file which contains the following command
copy /y "d:\downtime\report.htm" "\\server55\downtime\folder2"
The htm file is recreated every 10 minutes but occasionally the htm file is corrupted and has a filesize of 0, if this occurs i would like to prevent it being copied. Can anyone suggest how i might write something into the batch file to only copy the file of filesize is greater than 0 ?
Any advice appreciated
Cheers
Andy
copy /y "d:\downtime\report.htm" "\\server55\downtime\folder2"
The htm file is recreated every 10 minutes but occasionally the htm file is corrupted and has a filesize of 0, if this occurs i would like to prevent it being copied. Can anyone suggest how i might write something into the batch file to only copy the file of filesize is greater than 0 ?
Any advice appreciated
Cheers
Andy
#2
Something like:
FORFILES /P d:\downtime /M report.txt /C "cmd /c if @fsize GEQ 0 copy /y @file \\server55\downtime\folder2"
An extra exit would be needed to end the extra CMD session.
But that's off the top of my head, test it thoroughly!!
FORFILES /P d:\downtime /M report.txt /C "cmd /c if @fsize GEQ 0 copy /y @file \\server55\downtime\folder2"
An extra exit would be needed to end the extra CMD session.
But that's off the top of my head, test it thoroughly!!
#3
This command will return the length of the file.
So rather than echo %length%, use the parameter to check if length is 0
for %%a in (report.htm) do (
set length=%%~za
)
echo %length%
So rather than echo %length%, use the parameter to check if length is 0
for %%a in (report.htm) do (
set length=%%~za
)
echo %length%
#4
Scooby Regular
Thread Starter
Thanks to you LostUser also.. that may come in useful too.
#6
Scooby Regular
Thread Starter
Thread
Thread Starter
Forum
Replies
Last Post