Copying specific folder via batch file

Hi,

I'm new to scripting and I'm hoping someone can assist with the below required tasks:

I need to copy the below folder from C drive into F drive partition and if possible automate the copying using the Windows Task Scheduler

\Genie

I just need a batch file that I can use to fullfil the above required task.

Appreciate your generous help.
LVL 7
mcse2007Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

COBOLdinosaurCommented:
Why do you need a script? right click on the folder and select copy then right click on the f:drive and select past.

Or if you want to move it without keeping a copy in the current location just drag and drop the folder on the f: drive



Cd&
0
mcse2007Author Commented:
For backup purpose then automate it through Windows Task Scheduler.
0
NrisimhaCommented:

Hello mcse2007,

I can show you a BATCH DOS script to do that. So this is an example.

This code put in a file with extension .BAT. This is an example and click on .BAT file.

@echo off
echo.
echo.

F:

cd \

md "F:\My Computer\Favorites"

xcopy "C:\Documents and Settings\KORISNIK\Favorites\*.*" "F:\My Computer\Favorites" /S/E/Y


echo. All IE Favorites are copied to F: disk !!!
echo.
echo. The end of the job!!!
echo. Please press the any key on the keyboard to close this window !
echo.
pause

Open in new window


For eventually explanation ask me free.

Nrisimha

0
The Ultimate Tool Kit for Technolgy Solution Provi

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy for valuable how-to assets including sample agreements, checklists, flowcharts, and more!

NrisimhaCommented:

So for your folder C:\Genie you have this code for BAT script:

@echo off
echo.
echo.

F:

cd \

md "F:\Genie"

xcopy "C:\Genie\*.*" "F:\Genie" /S/E/Y


echo. All files from C:\Genie are copied to F:\Genie disk !!!
echo.
echo. The end of the job!!!
echo. Please press the any key on the keyboard to close this window !
echo.
pause

Open in new window


Nrisimha
0
COBOLdinosaurCommented:
0
mcse2007Author Commented:
Hi Nrisimha,

The /S copy, the /E copy empty folder, what's the /Y ?

Cheers
0
NrisimhaCommented:

Well, XCOPY command has many options. But I will answer to you on your question:

 /S           Copies directories and subdirectories except empty ones.

 /E           Copies directories and subdirectories, including empty ones.
                         Same as /S /E. May be used to modify /T.

So I use /S/E !!!

 /Y           Suppresses prompting to confirm you want to overwrite an
                          existing destination file.


I want to give you an advice if you want that your script works without a asking to press any key to close the window.

In such a case use only this code:

@echo off

F:
cd \
md "F:\Genie"
xcopy "C:\Genie\*.*" "F:\Genie" /S/E/Y

Open in new window



If there are any questions, here I am:))

Nrisimha
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Bill PrewCommented:
@mcse2007

If this is a backup need, what will happen the 2nd time this runs?  Will the destination folder exist from last backup, and do you want to overwrite?  If that is the case and you want a mirror of the live source folder, then robocopy with the /MIR option is probably the most appropriate.

As far as how to set up a job to run in the task scheduler just google for that and there are many good descriptions of that process available.

~bp
0
COBOLdinosaurCommented:
This will help you set it up  TASKS



Cd&
0
NrisimhaCommented:

Well, if anybody need Windows Command Reference - Windows 7/2008 then you can download a CHM file from:

http://www.microsoft.com/download/en/details.aspx?displaylang=en&=tm&id=2632

Nrisimha
0
mcse2007Author Commented:
Thanks for your help Nrisimha.

With your approach and attitude in solving problem, in no time, you will gain prominence here in EE. Well done mate and thanks for your help.
0
NrisimhaCommented:

Thank you mcse2007,

But I have to write something. If you want to enable Backup with an Genie folder that already exists on F: drive then use the next code:

@echo off

move "F:\Genie" "F:\Genie1"
md "F:\Genie"
xcopy "C:\Genie\*.*" "F:\Genie" /S/E/Y
rd "F:\Genie1" /S/Q

Open in new window



Nrisimha
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
VB Script

From novice to tech pro — start learning today.