samiam41
asked on
xcopy file except if file with same name is already present in dir
Hi EE. As I continue to build this monster batch file, I want to include code that checks if there is a file in the directory with the same name of the one being copied that the copy aborts and records this error. This is what I have so far:
Thank you for your help!
if not exist group xcopy \\myserver\nfs\group c:\tools\ /y && (
ECHO File was copied at %time% >>"%logfile%
) || (
ECHO File was not copied at %time% >>"%logfile%
)
In the code above, the script does check and skips the xcopy if the file is already in the directory but I would like for that action (file xcopy skipped) to be reported to the %logfile%. Thank you for your help!
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Is this for a whole range of files or one file?
ASKER
@point_pleasant, thanks. Testing now.
@lionelmm, two, small files.
@lionelmm, two, small files.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Hey BP! Good to see you again. I will shift my testing to this as it incorporates the error checking. Thank you.
ASKER
Two solid options that I have used in my script thus the split points. Thank you both for your help!
Follow up questions coming.
Follow up questions coming.
ASKER
if you have time, i would appreciate the additional expert eyes on this.
https://www.experts-exchange.com/questions/28260502/Perform-set-of-actions-only-on-servers-identified-in-the-script.html
https://www.experts-exchange.com/questions/28260502/Perform-set-of-actions-only-on-servers-identified-in-the-script.html
Welcome.
~bp
~bp