• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 749
  • Last Modified:

Batch Script which runs weekly?!?

Hi, i would like to write a batch script which is able to copy files from one shared folder to another folder every friday nite.  Is that possible for this loop thing to be done in batch script??  I also needs to exclude some files in the folder while copying.  Is this possible too?  please help~ thx

yours,
Vic
0
armansiu
Asked:
armansiu
1 Solution
 
pauldohertyCommented:
I'm not sure what the loop is that you're referring to, but you can schedule the task to run every Friday night in one of two ways.  One is to use The Task Scheduler (Start/Programs/Accessories/System Tools/Scheduled Tasks), and the other is to use the command-line scheduler, 'at'.  For example to schedule your BAT file named foldercopy.bat to run Friday nights at 2 AM:

at 02:00 /every:F "c:\batfiles\foldercopy.bat"

As for copying the files you can use xcopy to do this.  And you can use the /EXCLUDE:file.txt parameter to give it a list of files (or wildcards for files) that you don't want to be copied.  You put the entries into file.txt and store it somewhere (perhaps even the same batfiles directory).  And in each line of the file specify a file you don't want copied.  Like this:

file.txt:

dontcopy1.exe
meneither.exe
leavemealone.txt
file.txt


I'm sure you get the idea.  Then your BAT file would simply look like this (assuming drive maps to shares have been established on letters Z: and Y:):

@echo off
z:
cd \dirtocopyfrom
xcopy /y *.* y:\dirtocopyto\*.* /EXCLUDE:z:\dirtocopyfrom\file.txt
0
 
brianadkinsCommented:

Just a little additional info about 'AT'...

these tasks will be separate from those in the "Scheduled Tasks" GUI.  However, the Resource Kit has another utility called JT.EXE that also manages tasks from the command line AND they show up in the Task Scheduler.

http://www.jsiinc.com/subf/tip2600/rh2621.htm
http://www.experts-exchange.com/Networking/WinNT_Networking/Q_20349387.html

-Brian
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now