UBCD4Win Forums: Augment, upgrade a cmd-file - UBCD4Win Forums

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Augment, upgrade a cmd-file make an existing cmd better

#1 User is offline   bengt Icon

  • Skeptic
  • PipPipPipPipPipPip
    • Group: Donator/Beta Tester
    • Posts: 1,262
    • Joined: 16-December 05
    • Gender:Male
    • Location:Bork, bork, bork

    Posted 03 June 2009 - 06:08 PM

    I am using the following cmd file to do some backups of users files etc, but I would like to make it better and need help with that.
    At the moment it works just fine but as it is now, if I would like to do another backup a day later or so, it will overwrite the previous, so here comes the obvious...

    How do I change it so it will add a date or consecutive number to the following Backup folders?
    Like, Backup1, Backup2, etc or Backup(date), Backup(next date)

    abbreviated cmd-file

      @echo off
            :: variables
            set drive=C:\Backup
            set backupcmd=xcopy /s /c /d /e /h /i /r /y
    
            echo ### Backing up My Documents...
            %backupcmd% "%USERPROFILE%\My Documents" "%drive%\My Documents"
    
            echo ### Backing up Favorites...
            %backupcmd% "%USERPROFILE%\Favorites" "%drive%\Favorites"
    
            echo ### Backing up email and address book (Outlook Express)...
            %backupcmd% "%USERPROFILE%\Application Data\Microsoft\Address Book" "%drive%\Address Book"
            %backupcmd% "%USERPROFILE%\Local Settings\Application Data\Identities" "%drive%\Outlook Express"
    
            echo ### Backing up email and contacts (MS Outlook)...
            %backupcmd% "%USERPROFILE%\Local Settings\Application Data\Microsoft\Outlook" "%drive%\Outlook"
    
            echo ### Backing up the Registry...
            if not exist "%drive%\Registry" mkdir "%drive%\Registry"
            if exist "%drive%\Registry\regbackup.reg" del "%drive%\Registry\regbackup.reg"
            regedit /e "%drive%\Registry\regbackup.reg"
    
            echo Backup Complete!
            @pause

    0

    #2 User is offline   bengt Icon

    • Skeptic
    • PipPipPipPipPipPip
      • Group: Donator/Beta Tester
      • Posts: 1,262
      • Joined: 16-December 05
      • Gender:Male
      • Location:Bork, bork, bork

      Posted 03 June 2009 - 07:04 PM

      Doing this now...

      @echo off
      
      set drive=C:\Backup
      set backupcmd=xcopy /s /c /d /e /h /i /r /y
      
      ::Grabbing date variables...
      
      @For /F "tokens=1 delims=/ " %%A in ('Date /t') do set DD=%%A
      @For /F "tokens=2 delims=/ " %%B in ('Date /t') do set MM=%%B
      @For /F "tokens=3 delims=/ " %%C in ('Date /t') do set YY=%%C
      
      Set CUSTOMDATE=-%DD%%MM%%YY%
      
      echo ### Backing up My Documents...
      %backupcmd% "%USERPROFILE%\My Documents" "%drive%%CUSTOMDATE%\My Documents"
      
      echo ### Backing up Favorites...
      %backupcmd% "%USERPROFILE%\Favorites" "%drive%%CUSTOMDATE%\Favorites"
      
      echo ### Backing up email and address book (Outlook Express)...
      %backupcmd% "%USERPROFILE%\Application Data\Microsoft\Address Book" "%drive%%CUSTOMDATE%\Address Book"
      %backupcmd% "%USERPROFILE%\Local Settings\Application Data\Identities" "%drive%%CUSTOMDATE%\Outlook Express"
      
      echo ### Backing up email and contacts (MS Outlook)...
      %backupcmd% "%USERPROFILE%\Local Settings\Application Data\Microsoft\Outlook" "%drive%%CUSTOMDATE%\Outlook"
      
      echo ### Backing up the Registry...
      if not exist "%drive%%CUSTOMDATE%\Registry" mkdir "%drive%%CUSTOMDATE%\Registry"
      if exist "%drive%%CUSTOMDATE%\Registry\regbackup.reg" del "%drive%%CUSTOMDATE%\Registry\regbackup.reg"
      regedit /e "%drive%%CUSTOMDATE%\Registry\regbackup.reg"
      
      echo Backup Complete!
      @pause

      0

      #3 User is offline   chuckr_jcr Icon

      • Regular Member
      • PipPipPip
        • Group: Members
        • Posts: 136
        • Joined: 11-February 07
        • Location:Rocky Mountains area... CO
        • Interests:Learning more computer skills...

        Posted 03 June 2009 - 10:00 PM

        You might want to consider:

        Set CUSTOMDATE=_%YY%%MM%%DD%

        ;)


        Quote

        "Stop bothering me with stupid requests for plugins you silly retards can do on your own, alright?"

        This post has been edited by chuckr_jcr: 03 June 2009 - 10:08 PM

        "Inquiring minds would like to know..."
        0

        Page 1 of 1
        • You cannot start a new topic
        • You cannot reply to this topic

        1 User(s) are reading this topic
        0 members, 1 guests, 0 anonymous users