chandru0078 Posted May 5, 2009 Report Share Posted May 5, 2009 Hi ExpertsI 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 helpxcopy C:\GWC\PODSERVER\IMAGEFOLDER C:\TSMBACKUP /E /H /KC:\GWC\PODSERVER\IMAGEFOLDER\20090504\IWNM\035014011\[files] 20090504\INRM\035014011\ [files] \20090505\DDYF\035014011\[files] Quote Link to comment Share on other sites More sharing options...
Chris Posted May 5, 2009 Report Share Posted May 5, 2009 That should work, as the /E copies subdirs. and files.Do you have the correct folder/file permissions?You could also try adding an /Ixcopy C:\GWC\PODSERVER\IMAGEFOLDER C:\TSMBACKUP /E /H /K /IAlthough 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. Quote Link to comment Share on other sites More sharing options...
PatrickMc Posted May 19, 2009 Report Share Posted May 19, 2009 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 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.