Notices
Computer & Technology Related Post here for help and discussion of computing and related technology. Internet, TVs, phones, consoles, computers, tablets and any other gadgets.

DOS CMD Help

Thread Tools
 
Search this Thread
 
Old Apr 28, 2009 | 12:08 PM
  #1  
Avi's Avatar
Avi
Thread Starter
Scooby Regular
 
Joined: Apr 2001
Posts: 5,084
Likes: 0
From: Manchester
Default 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
Reply
Old Apr 28, 2009 | 12:22 PM
  #2  
HankScorpio's Avatar
HankScorpio
Scooby Regular
 
Joined: Feb 2004
Posts: 5,848
Likes: 0
Default

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!!
Reply
Old Apr 28, 2009 | 12:58 PM
  #3  
LostUser's Avatar
LostUser
Scooby Regular
 
Joined: Oct 2005
Posts: 476
Likes: 0
Default

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%
Reply
Old Apr 28, 2009 | 01:20 PM
  #4  
Avi's Avatar
Avi
Thread Starter
Scooby Regular
 
Joined: Apr 2001
Posts: 5,084
Likes: 0
From: Manchester
Default

Originally Posted by HankScorpio
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!!
This has done the job perfectlt - you are da man!

Thanks to you LostUser also.. that may come in useful too.
Reply
Old Apr 28, 2009 | 01:57 PM
  #5  
HankScorpio's Avatar
HankScorpio
Scooby Regular
 
Joined: Feb 2004
Posts: 5,848
Likes: 0
Default

Cool but just realised it should be "GEQ 1" or would also copy a zero size file.
Reply
Old Apr 28, 2009 | 02:26 PM
  #6  
Avi's Avatar
Avi
Thread Starter
Scooby Regular
 
Joined: Apr 2001
Posts: 5,084
Likes: 0
From: Manchester
Default

Originally Posted by HankScorpio
Cool but just realised it should be "GEQ 1" or would also copy a zero size file.
Yeah i did realise that when i tested it. Cheers again.
Reply
Related Topics
Thread
Thread Starter
Forum
Replies
Last Post
Darrell@Scoobyworx
Trader Announcements
26
Jan 30, 2024 01:27 PM
blackieblob
ScoobyNet General
4
Oct 1, 2015 11:37 AM
alcazar
Non Scooby Related
37
Sep 27, 2015 10:35 PM
StueyBII
General Technical
4
Sep 26, 2015 12:35 PM




All times are GMT +1. The time now is 04:22 AM.