Need help on DOS Batch files

J

JungleJim74

I use batch files for backup of my important files. After I have xcopied the
file I want to ECHO a notice to the user that the file has been backed up to
its new location but I need to check that the file, with the current date, is
actually there. How do I check that the file with the current date has
actually been copied to the destination file? Would something like this work?

IF EXISTS D:\BACKUP\Budget\Feb09\JLBudget2-1-09.xls ECHO The budget has been
backed up to the D:\BACKUP\Budget

I know that I need to add the check for the current date but I don't know
how to do it. Thanks in advance for any help. JungleJim74
 
P

Pegasus \(MVP\)

JungleJim74 said:
I use batch files for backup of my important files. After I have xcopied
the
file I want to ECHO a notice to the user that the file has been backed up
to
its new location but I need to check that the file, with the current date,
is
actually there. How do I check that the file with the current date has
actually been copied to the destination file? Would something like this
work?

IF EXISTS D:\BACKUP\Budget\Feb09\JLBudget2-1-09.xls ECHO The budget has
been
backed up to the D:\BACKUP\Budget

I know that I need to add the check for the current date but I don't know
how to do it. Thanks in advance for any help. JungleJim74

You could confirm it yourself by trial and error if your command would work.
It looks pretty good to me . . .

The date bit can be automated too. The exact method depends on the output
you get when you type this command at the Command Prompt:
echo %date%{Enter}

To make sure that the command works under all circumstances, you should
temporarily advance the PC's date to 1 March, then retype the above command
and post both outputs.
 
H

HeyBub

JungleJim74 said:
I use batch files for backup of my important files. After I have
xcopied the file I want to ECHO a notice to the user that the file
has been backed up to its new location but I need to check that the
file, with the current date, is actually there. How do I check that
the file with the current date has actually been copied to the
destination file? Would something like this work?

IF EXISTS D:\BACKUP\Budget\Feb09\JLBudget2-1-09.xls ECHO The budget
has been backed up to the D:\BACKUP\Budget

I know that I need to add the check for the current date but I don't
know how to do it. Thanks in advance for any help. JungleJim74

Delete the target file first, then check for its existence after the copy?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top