Solved

Batch file to backup directory

Posted on 2001-06-19
5
500 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The following is a collection of cases for strange behaviour when using advanced techniques in DOS batch files. You should have some basic experience in batch "programming", as I'm assuming some knowledge and not further explain the basics. For some…
Introduction: Recently, I got a requirement to zip all files individually with batch file script in Windows OS. I don't know much about scripting, but I searched Google and found a lot of examples and websites to complete my task. Finally, I was ab…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

732 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