Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7497163
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T18:57:36+00:00 2026-05-29T18:57:36+00:00

I have created the below batch file but no success. @ECHO OFF @ECHO Backup

  • 0

I have created the below batch file but no success.

@ECHO OFF

@ECHO "Backup process started."

@SET TARGET_FILES = "\\pc1\temp\*.mdb"
@ECHO "TARGET_FILES:%TARGET_FILES%"

@SET DESTINATION_FOLDER = "\\pc1\temp\Backups"
@ECHO "DESTINATION_FOLDER:%DESTINATION_FOLDER%"

@SET BACKUP_FOLDER = "Backup%date:~10,4%%date:~4,2%%date:~7,2%"
@ECHO "BACKUP_FOLDER:%BACKUP_FOLDER%"

@SET FINAL_FOLDER = "%DESTINATION_FOLDER%\%BACKUP_FOLDER%"
MKDIR %FINAL_FOLDER%
@ECHO "DIRECTORY CREATED:%FINAL_FOLDER%"

XCOPY %TARGET_FILES% %FINAL_FOLDER% >> %FINAL_FOLDER%\%BACKUP_FOLDER%.log

@ECHO "Backup process ended successfully."

@ECHO ON

Environment:
It will be scheduled task in C:\Windows\Tasks using Windows XP SP3

OUTPUT:

"Backup process started."
"TARGET_FILES:"
"DESTINATION_FOLDER:"
"BACKUP_FOLDER:"
The syntax of the command is incorrect.
"DIRECTORY CREATED:"
Invalid number of parameters
"Backup process ended successfully."

Any guidance on the right direction is appreciated.

UPDATES1:
I’ve noticed that my variables were not set.

UPDATES2:

@ECHO OFF
ECHO Backup process started.

set TARGET_FILES=\\pc1\temp\*.mdb
ECHO TARGET_FILES "%TARGET_FILES%"

SET DESTINATION_FOLDER=\\pc1\temp\Backups
ECHO DESTINATION_FOLDER "%DESTINATION_FOLDER%"

SET BACKUP_FOLDER=Backup%date:~0,4%%date:~5,2%%date:~8,2%
ECHO BACKUP_FOLDER "%BACKUP_FOLDER%"

SET FINAL_FOLDER=%DESTINATION_FOLDER%\%BACKUP_FOLDER%
MKDIR "%FINAL_FOLDER%"
ECHO DIRECTORY CREATED "%FINAL_FOLDER%"

XCOPY "%TARGET_FILES%" "%FINAL_FOLDER%" >> "%FINAL_FOLDER%\%BACKUP_FOLDER%.log"

ECHO Backup process ended successfully.

@ECHO ON

OUTPUT FOR UPDATES2:

Backup process started.
TARGET_FILES "\\pc1\temp\*.mdb"
DESTINATION_FOLDER "\\pc1\temp\Backups"
BACKUP_FOLDER "Backup20120214"
DIRECTORY CREATED "\\pc1\temp\Backups\Backup20120214"
Backup process ended successfully.

LOG

\\pc1\temp\file1.mdb
\\pc1\temp\file1_be.mdb
2 File(s) copied

With the new code (UPDATES2), I have successfully copied all mdb files to target folder but all my echo messages were not logged. How can I include all my echo messages to be logged?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T18:57:37+00:00Added an answer on May 29, 2026 at 6:57 pm

    I think you need add

    **cd /d %~dp0\**   
    

    (“%~dp0” can replace the runtime directory to the full path of the batch file)

    in your first line ..

    cd /d %~dp0 means cd /d d:\currentfolder

    UPDATE:

    Ok , I think you just want to copy your files from A to B .

    I create a sample for you base on your code.

    My folder is at

    D:\Run
    │  main.bat  >> the copy batch
    │  
    └─Test
        │  new.txt
        │  
        └─Backups
            └─20120214          >> created new folder
    

    the main.bat is

    @ECHO OFF
    
    cd /d %~dp0\
    
    ECHO Backup process started.
    
    SET TARGET_FILES="Test\*.txt"
    ECHO TARGET_FILES:%TARGET_FILES%
    
    
    SET DESTINATION_FOLDER=Test\Backups\%date:/=%
    ECHO DESTINATION_FOLDER:%DESTINATION_FOLDER%
    
    SET FINAL_FOLDER=%DESTINATION_FOLDER%
    ECHO FINAL_FOLDER:%FINAL_FOLDER%
    MD "%FINAL_FOLDER%"
    ECHO "DIRECTORY CREATED:%FINAL_FOLDER%
    
    XCOPY %TARGET_FILES% %FINAL_FOLDER%
    
    ECHO Backup process ended successfully.
    
    @ECHO ON
    

    i hope it would help you .

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have created a file with printStream object as shown below. PrintStream outPutOffice =
I have created a shell script (.sh) to extract a tar file. Below is
i have a batch(backup.bat)file.in that i have written a command to create a backup
i have created below function in a file info.php to debug variable & data
I have created button 2 below: <input id=Button1 type=button value=Stop onclick=alert('hello world');/> <input id=Button2
I have created one table using the below command: create table Table1( Id int
I have a dialog box, created with the code javascript and HTML generated below.
In my code I have 2 ComboBox DropDownLists, created by the code below. The
I have created below simple testcase in Delphi Prism . When I run the
I have created the TextBox and CompareValidator below which I thought would allow input

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.