batch file -Daily schedule copy whole folder and rename by DATE

Posted on 2009-12-30
Last Modified: 2012-05-08

I had daily job to copy  whole folder from Z:\DATA\SOURCE     to   D:\BACKUP\20091231  ,  rename the new folder   according YEAR & DATE------e.g.     "20091231" .

so i will had folders name:  20091228   , 20091229, 20091230, 20091231  ..................................................

How can i  command  a batch file to do backup---  scheduled  at 17:00  daily  ?

Question by:candychan611
    LVL 9

    Accepted Solution

    md D:\BACKUP\%date:~0,4%%date:~5,2%%date:~8,2%
    xcopy /Y /Q /S Z:\DATA\SOURCE D:\BACKUP\%date:~0,4%%date:~5,2%%date:~8,2%

    Copy and paste that into a batch file.

    You can use Windows Task Scheduler to automatically run your batch file everyday at 17:00

    LVL 9

    Assisted Solution


    Author Closing Comment

    Thanks , it works and save time for me :)

    Author Comment

    Hi Jeff_01,

    Your batch code  works when i click it manually.

    After i setting this  at  TASK Scheduler then do nothing.
    (Already  use other  software , it can open by TASK Scheduler normally )

    Here is my path :   (Y drive is   NAS storage   Z drive is old   norvell netware  server  )

    md Y:\FoxproserverBackup\%date:~0,4%%date:~5,2%%date:~8,2%
    xcopy /Y /Q /S Z:\HKMDATA Y:\FoxproserverBackup\%date:~0,4%%date:~5,2%%date:~8,2%
    LVL 9

    Expert Comment

    Hmm, maybe its a permissions thing.

    If you right click on the task then click properties.

    In the RunAs section type your username and then click on set password and type in your password.

    This will allow the task to run with your credentials. Try that and lets see what happens.


    Author Comment


    The reason of failure:   .bat place at a  FOLDER  names   included    space, marks  and  chinese character , it seems  not support.

    After rename it  all fixed.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Better Security Awareness With Threat Intelligence

    See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

    Suggested Solutions

    iTunes uses a third party component from  GEAR Software ( for accessing the CD/DVD drives in Windows computers.  This component is registered as a filter driver for all CD/DVD drives.  Sometimes the iTunes installation or…
    Migration of Exchange mailbox can be done with the ExProfre.exe tool. But at times, when the ExProfre.exe tool migrates the Exchange Server user profile, it results in numerous synchronization problems. Synchronization error messages appear in the e…
    how to add IIS SMTP to handle application/Scanner relays into office 365.
    Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

    759 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