We're aware that some users are experiencing technical issues which the team are working to resolve. See the Community Noticeboard for more info. Thank you for your patience.
📨 Have you signed up to the Forum's new Email Digest yet? Get a selection of trending threads sent straight to your inbox daily, weekly or monthly!

Batch files

Options
rmg1
rmg1 Posts: 3,159 Forumite
Part of the Furniture 1,000 Posts Name Dropper
Morning all

I've got a batch file which copies files to a separate folder on a hard drive for (dodgy) backup purposes.
Here's the code:-
f:
rem Kill off the Grandfather archive
f:
cd\
cd Grandfather_Backups
del symposiumbackup.bak
del CCCbackup.bak
del NOCReporting.bak
del NPFS.bak
del Sandpit.bak
del Staging.bak
del reference.bak
del reports.bak
del 111_Adastra_Local.bak
del 111_Adastra_Reference.bak
del 111_Adastra_Reporting.bak
del 111_Adastra_Staging.bak
rem Copy Father to Grandfather
f:
cd\
copy Father_Backups\symposiumbackup.bak Grandfather_Backups\symposiumbackup.bak
copy Father_Backups\CCCbackup.bak Grandfather_Backups\CCCbackup.bak
copy Father_Backups\NOCReporting.bak Grandfather_Backups\NOCReporting.bak
copy Father_Backups\NPFS.bak Grandfather_Backups\NPFS.bak
copy Father_Backups\Sandpit.bak Grandfather_Backups\Sandpit.bak
copy Father_Backups\Staging.bak Grandfather_Backups\Staging.bak
copy Father_Backups\reference.bak Grandfather_Backups\reference.bak
copy Father_Backups\reports.bak Grandfather_Backups\reports.bak
copy Father_Backups\111_Adastra_Local.bak Grandfather_Backups\111_Adastra_Local.bak
copy Father_Backups\111_Adastra_Reference.bak Grandfather_Backups\111_Adastra_Reference.bak
copy Father_Backups\111_Adastra_Reporting.bak Grandfather_Backups\111_Adastra_Reporting.bak
copy Father_Backups\111_Adastra_Staging.bak Grandfather_Backups\111_Adastra_Staging.bak


It doesn't seem to be working even though I've checked all the filenames are correct and the paths are correct.
The scheduled task which runs it gives a code 0x1 which appears to be something to do with a bad filename or command.

Anyone any ideas?
:wall: Flagellation, necrophilia and bestiality - Am I flogging a dead horse? :wall:

Any posts are my opinion and only that. Please read at your own risk.

Comments

  • Nothing wrong with the syntax of the .bat

    It's years since I did any scheduled tasks but 0x1 is an unknown function. Is the scheduled task calling on the right batch file or have you moved it or changed its name while you've been editing it?
    I'm dreaming of a white Christmas.
    But, if the white runs out, I'll drink the red.

  • rmg1
    rmg1 Posts: 3,159 Forumite
    Part of the Furniture 1,000 Posts Name Dropper
    I didn't think I had, but I'll double-check the path and filename.
    Thanks for checking the syntax.
    :wall: Flagellation, necrophilia and bestiality - Am I flogging a dead horse? :wall:

    Any posts are my opinion and only that. Please read at your own risk.
  • Mista_C
    Mista_C Posts: 2,202 Forumite
    Part of the Furniture Combo Breaker
    The 0x1 status just notifies that the task encountered 'some' error. My OHs home folder backups nearly always end in 0x1 due to her not closing Outlook, leaving the mail folders in use by the system.

    As WhiteChristmas says the syntax looks fine. Check the date stamps of the files in the Grandfather backups and see if they match. If you find one that doesn't have the most recent date on it then you should have a starting point of which file to look at. It's likely to be a file still in use, or a permissions issue.

    You could also suffix >> x:\error.txt 2>&1 to your copy command lines so that the error outputs to an error log called 'x:\error'txt' (x being the letter of the drive you want the log to be created) which you can read back later for a better idea of the problem.
  • rmg1
    rmg1 Posts: 3,159 Forumite
    Part of the Furniture 1,000 Posts Name Dropper
    I'm an idiot! :o

    It does help if you remember not to try and copy files that don't exist any more. :wall:
    :wall: Flagellation, necrophilia and bestiality - Am I flogging a dead horse? :wall:

    Any posts are my opinion and only that. Please read at your own risk.
  • John_Gray
    John_Gray Posts: 5,843 Forumite
    Part of the Furniture 1,000 Posts Name Dropper Photogenic
    Try running it in a Command Prompt window, and you will then see any error.

    Or start the BATch file with something like
    Grandfather.bat 1>GF.txt 2>&1
    (much like Mista_C put on each copy command) you will get the entire console output in the GF.txt file. But you may have to press Enter one or more times to get the BATch file to finish, if it comes up with a question (which of course you cannot see).
  • rmg1 wrote: »
    I'm an idiot! :o

    It does help if you remember not to try and copy files that don't exist any more. :wall:


    I wonder if we should be petitioning for the addition of a "Point and Laugh" button alongside "Thanks"? ;o)
    I'm dreaming of a white Christmas.
    But, if the white runs out, I'll drink the red.

This discussion has been closed.
Meet your Ambassadors

🚀 Getting Started

Hi new member!

Our Getting Started Guide will help you get the most out of the Forum

Categories

  • All Categories
  • 350.8K Banking & Borrowing
  • 253K Reduce Debt & Boost Income
  • 453.5K Spending & Discounts
  • 243.8K Work, Benefits & Business
  • 598.6K Mortgages, Homes & Bills
  • 176.8K Life & Family
  • 257.1K Travel & Transport
  • 1.5M Hobbies & Leisure
  • 16.1K Discuss & Feedback
  • 37.6K Read-Only Boards

Is this how you want to be seen?

We see you are using a default avatar. It takes only a few seconds to pick a picture.