Link to home
Start Free TrialLog in
Avatar of mcse2007
mcse2007Flag for Australia

asked on

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.
Avatar of COBOLdinosaur
COBOLdinosaur
Flag of Canada image

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&
Avatar of mcse2007

ASKER

For backup purpose then automate it through Windows Task Scheduler.

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


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
Hi Nrisimha,

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

Cheers
ASKER CERTIFIED SOLUTION
Avatar of Nrisimha
Nrisimha
Flag of Croatia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Bill Prew
Bill Prew

@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
This will help you set it up  TASKS



Cd&

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
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.

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