Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: Batch filebackup to date stamped folder  (Read 2645 times)

0 Members and 1 Guest are viewing this topic.

ali3148

    Topic Starter


    Newbie

    Batch filebackup to date stamped folder
    « on: October 05, 2009, 01:39:01 PM »
    I am doing a project where i have to create a menu system to backup files to a specific location, backup files that have been created since last backup and offer a restore files option. The only problem i have is how to get the program to copy all files from a specific folder to a date stamped folder. Any help appreciated

    Salmon Trout

    • Guest
    Re: Batch filebackup to date stamped folder
    « Reply #1 on: October 05, 2009, 02:04:41 PM »
    please show your local date format setting

    here's mine for example

    Code: [Select]
    C:\>echo %date%
    05/10/2009

    ali3148

      Topic Starter


      Newbie

      Re: Batch filebackup to date stamped folder
      « Reply #2 on: October 05, 2009, 02:08:59 PM »
      My date setting is the same as yours

      Salmon Trout

      • Guest
      Re: Batch filebackup to date stamped folder
      « Reply #3 on: October 05, 2009, 02:27:39 PM »
      use string slicing to get the YYYY MM and DD parts out of %date% and the mkdir command to create the folder named as you want

      slice a string thus %string:offset,length% offset is the offset from the start (0 is 1st char) and length is the no of chars.

      THis should give you the idea, and also something to build on...

      Code: [Select]
      set dd=%date:~0,2%
      set mm=%date:~3,2%
      set yyyy=%date:~6,4%
      set newfolder=%yyyy%-%mm%-%dd%
      if not exist %newfolder% mkdir %newfolder%
      copy myfolder\*.* %newfolder%