Batch Script which runs weekly?!?

Posted on 2004-10-22
Last Modified: 2012-08-14
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

Question by:armansiu
    LVL 1

    Accepted Solution

    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:



    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
    cd \dirtocopyfrom
    xcopy /y *.* y:\dirtocopyto\*.* /EXCLUDE:z:\dirtocopyfrom\file.txt
    LVL 5

    Expert Comment


    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.


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Highfive + Dolby Voice = No More Audio Complaints!

    Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

    Using dates in 'DOS' batch files has always been tricky as it has no built in ways of extracting date information.  There are many tricks using string manipulation to pull out parts of the %date% variable or output of the date /t command but these r…
    VALIDATING DATES One method of validating dates is to jam the date into the DATE command and see if it accepts it by examining the system's errorlevel value. A non-zero result indicates failure. A typical example might look something like the fol…
    Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…
    Hi everyone! This is Experts Exchange customer support.  This quick video will show you how to change your primary email address.  If you have any questions, then please Write a Comment below!

    761 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

    10 Experts available now in Live!

    Get 1:1 Help Now