Search : in
By :

Creating a Batch File to copy a directory

Last answer on Nov 3, 2009 1:24:52 pm GMT Waqas, on Oct 15, 2008 4:37:32 pm BST 
 Report this message to moderators

Hello,

I have a directory / folder on my desktop and sub-directories / sub-folders in it and various files in various directories.
at the end of the day i want to copy those folders and files accordingly to flash drive lets say f:\ (f drive).

I would like to create a batch file which copies my folders and files as it is as the original ones with same paths. The batch file should be such as that it shoud only copy those files or folders which are changed and rest should remain same. no need to copy the whole directory again and again.....

Can u please give me the commands for the said.

Waiting for your replies....

Configuration: Windows XP
Internet Explorer 7.0

Best answers for « Creating a Batch File to copy a directory » in :
[Shell]Create a file having a specific size ShowShell]Create a file having a specific size The dd command allows you to create "empty" file of desired size, creating these arbitrary heavy files, may be useful for testing purposes. Use command below: dd if=/dev/zero of=file_to...
What is a batch file? ShowWhat is a batch file? Creating a batch file Prerequisites Create file Windows comes with a version of DOS, which allows you,exploiting the features and the sequence of commands in a script. Batch file, is a simple text file (ascii)...
Batch file ShowBatch file Settings File Creation DOS is integrated in windows which allow to exploit functionality and command sequence in a script. A batch file is a text file which contains command to be read by DOS. This file can be launched...
UNIX Commands ShowTable of the main UNIX commands Unix Commands Description Options ls lists the content of a directory -a Displays all files, including hidden files -I Displays a...
UNIX - Files ShowIntroduction to UNIX files In UNIX systems any element is represented in the form of a file. All files are architectured around a single tree structure where the base, called the root, is written "/". File types UNIX systems define different...

1

xpcman, on Oct 15, 2008 9:59:17 pm BST

Why not use SyncToy from Microsoft?

check this link

http://blogs.msdn.com/...

Reply to xpcman

2

Igo309, on Oct 30, 2008 12:23:13 pm GMT
  • +2

Try XCOPY with parameter /S or /E

example:

XCOPY C:\Temp C:\Temp2 /S

Reply to Igo309

3

fuckingmoron, on Nov 2, 2008 11:26:43 am GMT
  • +2

Xcopy source destination /D /I

if you want you can add more switches , check out : xcopy /?

Reply to fuckingmoron

7

Tanyaa, on Mar 16, 2009 11:32:45 am GMT

Hyaaa

Reply to Tanyaa

4

khurram, on Nov 12, 2008 9:09:13 am GMT
  • +1

Try xcopy source destination /D parametr
/D:m-d-y Copies files changed on or after the specified date. If no date is given, copies only those files whose source time is newer than the destination time.
also check link
http://www.computerhope.com/xcopyhlp.htm

Reply to khurram

5

Jake, on Dec 25, 2008 6:11:48 am GMT
  • +8

Here is what i use to copy all my user documents over to a destination drive in XP and Vista...

XCOPY "C:\Users" "K:\My Vista Backup" /D /E /C /R /I /K /Y

XCOPY "C:\DOCUME~1" "I:\My XP Backup" /D /E /C /R /I /K /Y

works like a charm

Reply to Jake

8

the batcher(learner), on Sep 26, 2009 8:15:00 pm BST

What are the /D /E /C /R /I /K /Y for, are they variables that should be input like are they specific dates/years/time a day or something else that is specific to the materiel you are trying to copy or are they just some standards you have to type in the batch file, like are they commands? hope to get an answer soon though I know it is long ago you provided this answer

Reply to the batcher(learner)

9

Luke, on Oct 25, 2009 7:23:14 pm GMT
  • +1

Hey, they're called switches - they're extra parameters that make the command do a more specific and targeted job (given what the above switches for this command mean below)

  /D:m-d-y     Copies files changed on or after the specified date. If no date is given, copies only those files whose source time is newer than the destination time. (His suggestion contains no date so all files in that directory - and sub directories (even if empty 'cause of /E) are copied over if newer than the versions in the place they're being copied to.)
  /E    Copies directories and subdirectories, including empty ones. Same as /S /E. May be used to modify /T.
  /C     Continues copying even if errors occur.
  /R     Overwrites read-only files.
  /I      If destination does not exist and copying more than one file, assumes that destination must be a directory.
  /K     Copies attributes. Normal Xcopy will reset read-only attributes.
  /Y     Suppresses prompting to confirm you want to overwrite.

Windows Vista has tried to replace this with Robocopy (Robust File Copy for Windows), but xcopy will still work :)

Reply to Luke

10

 thebatcher(learner), on Nov 3, 2009 1:24:52 pm GMT

Hey thank you for the answer that was really very helpfull.

Reply to thebatcher(learner)

6

bad guy, on Mar 10, 2009 4:18:32 am GMT
  • +1

To copy entire directry


xcopy sourcepath destinationpath /e

Reply to bad guy