Jump to content

xcopy bat script for windows 2003


Recommended Posts

Hi Experts

I need some to help me on bat scripting. I need to copy folder from C:\GWC\PODSERVER\IMAGEFOLDER to C:\TSMBACKUP

but the problem is under C:\GWC\PODSERVER\IMAGEFOLDER there is folder and subfolder and also files. I have tried to use xcopy,copy.robo and many other way.Nothing is giving me what i need.As you can below see when i used xcopy its NOT copying some files from the subfolder !!!.how to copy folder and thier subfolder based on the system day.I only need to copy 20090505 folder and subfolder today and tomorrow follow by 20090506(will create by application) folder and subfolder.? Please help

xcopy C:\GWC\PODSERVER\IMAGEFOLDER C:\TSMBACKUP /E /H /K

C:\GWC\PODSERVER\IMAGEFOLDER\20090504\IWNM\035014011\[files]

20090504\INRM\035014011\ [files]

\20090505\DDYF\035014011\[files]

Link to comment
Share on other sites

That should work, as the /E copies subdirs. and files.

Do you have the correct folder/file permissions?

You could also try adding an /I

xcopy C:\GWC\PODSERVER\IMAGEFOLDER C:\TSMBACKUP /E /H /K /I

Although running this everyday wouldn't be good as it would ask you to overwrite existing files in C:\TSMBACKUP.

So you would need to add /Y but this would copy and overwrite everything; which may take sometime so you could use /D which only copies newer files.

Experiment.

Link to comment
Share on other sites

  • 2 weeks later...

Hi chandru0078:

Nice question. The way I understand your requirements:

Every day, you want to create a folder for today's date (20090519) under C:\TSMBACKUP, then copy the entire folder structure (files included) from C:\GWC\PODSERVER\IMAGEFOLDER to that folder. You want to use xcopy.

This should be pretty easy. Here is a little script. It is written using biterscripting. ( http://www.biterscripting.com/install.html for installation. It is free.)

# Script backup.txt
# Get today's date.
var string today; set $today = gettime(); chex "8[" $today > null

# Today's date in 20090519 form is in $today. Make today's directory.
system mkdir ("C:\TSMBACKUP\"+$today)

system xcopy "C:\GWC\PODSERVER\IMAGEFOLDER" ("C:\TSMBACKUP\"+$today) "/E" "/H" "/K"

Save this script in file C:\Scripts\backup.txt. Schedule the following command to run from task scheduler.

"C:\biterScripting\biterScripting.exe" "C:\Scripts\backup.txt"

Every day's files will automatically copied to that day's folder.

Patrick

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. Privacy Policy