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

Author Topic: Creating a .bat backup program not working  (Read 3712 times)

0 Members and 1 Guest are viewing this topic.

alyoob

    Topic Starter


    Intermediate

    Thanked: 1
    • Experience: Experienced
    • OS: Windows 8
    Creating a .bat backup program not working
    « on: February 28, 2010, 04:21:03 PM »
    I am trying to execute a backup program using notepad then saving the file as a .bat so the at it will execute / run the backup program to save my content to another hard drive.   I tried the original code and it worked fine it transferred the content in c:\testsource to c:\testbackup when i try to change the destination folder to another folder and tried the program again it did not transfer the content in c:\testbackup to the other folder. Can somebody show me what i am doing wrong.

    @echo off
    xcopy c:\testsource c:\testbackup /m /e /y

    Azzaboi



      Apprentice
    • Aaron's Game Zone
    • Thanked: 37
      • Aaron's Game Zone
    • Experience: Experienced
    • OS: Windows 7
    Re: Creating a .bat backup program not working
    « Reply #1 on: February 28, 2010, 04:55:59 PM »
    Whats the folder you are trying to change it to?

    And by the way, it would not transfer the content in 'c:\testbackup' to the other folder unless you had that as the source which is currently 'c:\testsource'? Make sure either this was a typo or you might be doing it backwards. The  xcopy DOS command to copy all contents of the c:\testsource directory to the c:\testbackup.

    XCOPY is similar to the COPY command except that it has additional switches to specify both the source and destination in detail.

    /M Copies only files with the archive attribute set, turns off the archive attribute.
    /E Copies directories and subdirectories, including empty ones.
    /Y Suppresses prompting to confirm you want to overwrite an existing destination file.

    You might be having issue with the directory length and/or spacing.
    Aaron's Game Zone
    The best free online flash games: http://azzaboi.weebly.com

    Play Games - Play free games at Play Games Arcade

    BC_Programmer


      Mastermind
    • Typing is no substitute for thinking.
    • Thanked: 1140
      • Yes
      • Yes
      • BC-Programming.com
    • Certifications: List
    • Computer: Specs
    • Experience: Beginner
    • OS: Windows 11
    Re: Creating a .bat backup program not working
    « Reply #2 on: February 28, 2010, 05:00:57 PM »
    If any folder name contains spaces it must be enclosed in quotes.
    I was trying to dereference Null Pointers before it was cool.

    alyoob

      Topic Starter


      Intermediate

      Thanked: 1
      • Experience: Experienced
      • OS: Windows 8
      Re: Creating a .bat backup program not working
      « Reply #3 on: February 28, 2010, 05:11:22 PM »
      Thank you Azzaboi and BC_Programmer for your tips it worked out.

      BC_Programmer


        Mastermind
      • Typing is no substitute for thinking.
      • Thanked: 1140
        • Yes
        • Yes
        • BC-Programming.com
      • Certifications: List
      • Computer: Specs
      • Experience: Beginner
      • OS: Windows 11
      Re: Creating a .bat backup program not working
      « Reply #4 on: February 28, 2010, 05:13:44 PM »
      Here is the folder that i want to transfer to C:\Documents and Settings\HP_Owner\My Documents\My Music
      should there be quotes because and you show me how to type it.

      Code: [Select]
      xcopy c:\testsource "C:\Documents and Settings\HP_Owner\My Documents\My Music" /m /e /y

      if your source folder also contains quotes you'll need to place quotes around it in the same manner.
      I was trying to dereference Null Pointers before it was cool.