Solved

Batch file to backup directory

Posted on 2001-06-19
5
495 Views
Last Modified: 2008-03-17
Hi,

this is a rather simple task, but I've forgotten the exact commands. I want the batch file to run under scheduler in this way:

1 - at 6pm, scheduler runs the backup.bat file, NO command prompt windows should pop up. (Win95/98).

2 - batch files does an XCOPY [dir1] [dir2]. with /S /E /C /H /Y . did I miss out anything? I want it to copy over updated and new files only. not the entire directory.

3 - manual clicking the batch file should run the XCOPY too. how do I do it without popping up the command window?


thanks!

doebuck

0
Comment
Question by:doebuck
5 Comments
 
LVL 11

Expert Comment

by:griessh
ID: 6210257
1) Since you are running on 95/98 I would suggest to use a tool like WinCron (works lke a crontab under UNIX). To my knowledge the AT command is not implemented in 95/98.
2) I would add the /M option. This will allow to only copy files with the archive bit set and it will reset the archive bit on these files.

======
Werner
0
 
LVL 7

Accepted Solution

by:
rin1010 earned 120 total points
ID: 6210797

doebuck,

Along with the parameters you're using, add the /i and /k switches...
The /i switch eliminates prompting about a directory if your copying multiple files.
The /k switch will copy the file's attributes and not reset any read-only attributes.
This may not apply to what you're currently copying but may be needed at some future time.
Also note that some of these switches apply only when running XCOPY under Windows
as you specify, but are the ones to get everything.

To copy "updated and new files only" append the /d switch, which copies only newer files
if a date isn't given. Alternatively, the /m switch will copy only changed files
but will alter the archive attribute to manipulate the files.

Using your examples, the batch file would be something like this:

::backup.bat
@echo off
xcopy /h /i /c /k /e /r /y /d dir1 dir2
cls


To get the batch file to run minimized, create a PIF to control it.
In Explorer, right-click your batch file and choose "Properties" from the ensuing menu.
In the "Run" field on the "Program" tab select "Minimized."
Adding CLS as the last line of your batch file will make it close under Windows,
but you can also choose the option to "Close on Exit" in the PIF properties.
You may find other useful PIF properties under some of the tabs
that will apply to your batch file.

Please post back if you want more about it or if these methods don't do it like you want.
 
0
 
LVL 11

Expert Comment

by:LambertHeenan
ID: 6211152
rin1010

CLS clears the screen in a batch file. I take it you meat to use EXIT
0
 
LVL 7

Expert Comment

by:rin1010
ID: 6211507

Thanks, Lambert, but no, I meant that the CLS (clear screen) command
will close a dos box (window) when affixed as the last line of a batch file
running under the Windows versions doebuck mentions.
The EXIT command would terminate and remove from memory
the current copy of the COMMAND.COM command interpreter
and would close it if you shelled a dos session and ran it manually.

But in the context of "clicking the batch file" as doebuck indicates,
as opposed to typing the batch file's name in a Windows dos box,
you can test it yourself with a couple of simple batch files...

::xcomspec.bat
exit

::closebox.bat
cls


If the batch file is run from a shortcut or winfile or explorer or in a similar manner,
when the screen is cleared the window will close. Other results will occur
depending on previous commands in the script and whether it's run in dos mode, etc.,
where you probably wouldn't want to use the exit command. To see what I mean,
launch these examples from explorer and then manually from a command prompt:

::
@echo off
exit

::
@echo off
cls

::
@echo off
dir
exit

::
@echo off
dir
cls

 
0
 
LVL 1

Author Comment

by:doebuck
ID: 6241843
hey thanks guys!
I thought nobody bothered answering my question, as my email did not notify me for quite sometime.

rin1010, thanks. that's really what I need. BTW, do you know if it's possible still, to make a 'synchronization' instead of a backup, from a batch file?

say if dir1\file1 and dir2\file1 is compared and if the latter is newer than the former, it'll overwrite the other way round?
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

TOMORROW TOMORROW.BAT is inspired by a question I get asked over and over again; that is, "How can I use batch file commands to obtain tomorrow's date?" The crux of this batch file revolves around the XCOPY command - a technique I discovered w…
YESTERDAY YESTERDAY.BAT is inspired by a previous article I wrote entitled: TOMORROW.BAT (http://www.experts-exchange.com/OS/Microsoft_Operating_Systems/MS_DOS/A_4196-Advanced-Batch-File-Programming-TOMORROW-BAT.html). The crux of this batch f…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now