views:

366

answers:

2

I need to create a batch file which will copy web log files from a web server to a local desktop box on daily frequency.

I'm a web developer, but I'd like to take a stab at learning the process for creating a batch file and I think using the windows scheduler should get me where I need to go.

In any case, I'm just looking for a jumping off point.

I understand the premise behind a batch file (echo to print info, commands to cause actions such as mkdir or move, etc), but some straight forward tutorials would be great.

Or even a reference guide such as devguru.com or 4guysfromrolla.com would be helpful.

Thanks,

+1  A: 

Creating a batch file is relatively straightforward.

Just type out the commands you want as you would in the command shell, and save the file with a .bat extension.

There's a simple example here that you may find useful. Note, you can use any editor to create your batch file, as long as it saves in a text format.

Depending on which version of Windows you're using, the process to create a scheduled task is slightly different:

Edit: A little followup on misteraiden's answer.

Essentially, what you're looking for is scripting functionality. There are a variety of tools available. A batch file is the simplest form of scripting that Windows supports. You could, for example, write scripts in PowerShell or Python. Both are more powerful and flexible scripting languages. Depending on what the requirements are for your script, and what you feel like learning, they may be more appropriate.

However, If all you want to do is a copy, the simplest, easiest place to start is a batch file.

Nader Shirazie
A: 

This is a little left-of-field, but using an XML build interpreter such as NAnt could come in handy here. Probably over-kill for what you are trying to do, but if you learn it now, you'll be able to apply it's uses in many different places.

You could use Windows Scheduler to trigger the build, which would then complete various operations such as deleting, copying, logging on to network shares.

However, perhaps to learn this you would probably need to learn more about the command line and command line programming.

Either way, I recommend you check out some of the NAnt examples that deal with copying and other basics etc..

misteraidan