Solved

Need copy  changed and new files only from one directory to another.

Posted on 2001-06-08
4
727 Views
Last Modified: 2013-12-28
Need copy files from one directory to another.  These directories/subdirectories are supposed to be the same.  However, one of the directories had many changes applied to it during the last week.  Consequently, I would like to copy only files which have changed or have been added to the directory/subdirectories only during the last week.  Any ideas?
0
Comment
Question by:losgadas
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 2

Expert Comment

by:Macros
ID: 6168271
You can use Robocopy from the Resource Kit.

Syntax:

Robocopy <source> <destination> /MAXAGE:n

MAXAGE excludes files older that "n" days or date. If n is less than 1900 it is the number of days. Otherwise it is a date in the format YYYYMMDD. In your case you could just use 7 for all files added or modified in the last 7 days.

Read Robocopy.doc in the Resource Kit directory for all the switches - it's a very useful tool.

If you don't have the Resource Kit you can use
XCOPY source destination /D:m-d-y
which will copy file changed on or after the specified date. The limitation of this is that you will want to change the date on it every time you run it if you are using it regularily.
0
 
LVL 10

Expert Comment

by:tonnybrandt
ID: 6168728
Or simply use the xcopy command with the /m parameter. This checks for the archive attribute and if it is set it copies it and clears the attribute. Every time a file is written, whether it is a new or changed file, the archive attribute is set, so this is IMHO the best and most thorough method.

Here is the complete listing of parameters to the xcopy command:

E:\>xcopy /?
Copies files and directory trees.

XCOPY source [destination] [/A | /M] [/D[:date]] [/P] [/S [/E]] [/V] [/W]
                           [/C] [/I] [/Q] [/F] [/L] [/H] [/R] [/T] [/U]
                           [/K] [/N] [/O] [/X] [/Y] [/-Y] [/Z]
                           [/EXCLUDE:file1[+file2][+file3]...]

  source       Specifies the file(s) to copy.
  destination  Specifies the location and/or name of new files.
  /A           Copies only files with the archive attribute set,
               doesn't change the attribute.
  /M           Copies only files with the archive attribute set,
               turns off the archive attribute.
  /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.
  /EXCLUDE:file1[+file2][+file3]...
               Specifies a list of files containing strings.  When any of the
               strings match any part of the absolute path of the file to be
               copied, that file will be excluded from being copied.  For
               example, specifying a string like \obj\ or .obj will exclude
               all files underneath the directory obj or all files with the
               .obj extension respectively.
  /P           Prompts you before creating each destination file.
  /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.
  /V           Verifies each new file.
  /W           Prompts you to press a key before copying.
  /C           Continues copying even if errors occur.
  /I           If destination does not exist and copying more than one file,
               assumes that destination must be a directory.
  /Q           Does not display file names while copying.
  /F           Displays full source and destination file names while copying.
  /L           Displays files that would be copied.
  /H           Copies hidden and system files also.
  /R           Overwrites read-only files.
  /T           Creates directory structure, but does not copy files. Does not
               include empty directories or subdirectories. /T /E includes
               empty directories and subdirectories.
  /U           Copies only files that already exist in destination.
  /K           Copies attributes. Normal Xcopy will reset read-only attributes.
  /N           Copies using the generated short names.
  /O           Copies file ownership and ACL information.
  /X           Copies file audit settings (implies /O).
  /Y           Suppresses prompting to confirm you want to overwrite an
               existing destination file.
  /-Y          Causes prompting to confirm you want to overwrite an
               existing destination file.
  /Z           Copies networked files in restartable mode.

The switch /Y may be preset in the COPYCMD environment variable.
This may be overridden with /-Y on the command line.
0
 
LVL 11

Accepted Solution

by:
LambertHeenan earned 30 total points
ID: 6168736
good old Xcopy (available since MS-DOS 3.0) can hadle that.

xcopy \SourceDir\*.* \DestDir /S /A /D:m-d-y

/S -- process sub-dirs too
/A -- process files with the archive bit st (as all changed files will have)
/D -- process files dated on or after the supplied date

XCOPY /? for full syntax details

If you do this every week then you only need the /A switch for xcopy to locate any files changed since the lst time.
0
 
LVL 27

Expert Comment

by:Asta Cu
ID: 6173673
losqadas,

    You have asked a new question, again experts have stepped in to help you, but no closure or response.  You have a number of open question awaiting your return and update and/or finalization.  Please do keep your open items active so that you can get what you seek and finalize your open items, awarding those who have helped you.

Thanks,

Asta
0

Featured Post

Are You Using the Best Web Development Editor?

The worlds of web hosting and web development are constantly evolving. Every year we see design trends change, coding standards adapt and new frameworks/CMS created. With such a quick pace of change it’s easy to get lost trying to keep up.

See if your editor made the list.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When asking a question in a forum or creating documentation, screenshots are vital tools that can convey a lot more information and save you and your reader a lot of time
Sometimes clients can lose connectivity with the Lotus Notes Domino Server, but there's not always an obvious answer as to why it happens.   Read this article to follow one of the first experiences I had with Lotus Notes on a client's machine, my…
This Micro Tutorial will give you a basic overview of Windows DVD Burner through its features and interface. This will be demonstrated using Windows 7 operating system.
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…

623 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question