Solved

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

Posted on 2001-06-08
4
712 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

Easy, flexible multimedia distribution & control

Coming soon!  Ideal for large-scale A/V applications, ATEN's VM3200 Modular Matrix Switch is an all-in-one solution that simplifies video wall integration. Easily customize display layouts to see what you want, how you want it in 4k.

Question has a verified solution.

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

Join Greg Farro and Ethan Banks from Packet Pushers (http://packetpushers.net/podcast/podcasts/pq-show-93-smart-network-monitoring-paessler-sponsored/) and Greg Ross from Paessler (https://www.paessler.com/prtg) for a discussion about smart network …
While rebooting windows server 2003 server , it's showing "active directory rebuilding indices please wait" at startup. It took a little while for this process to complete and once we logged on not all the services were started so another reboot is …
The viewer will learn how to successfully create a multiboot device using the SARDU utility on Windows 7. Start the SARDU utility: Change the image directory to wherever you store your ISOs, this will prevent you from having 2 copies of an ISO wit…
With the advent of Windows 10, Microsoft is pushing a Get Windows 10 icon into the notification area (system tray) of qualifying computers. There are many reasons for wanting to remove this icon. This two-part Experts Exchange video Micro Tutorial s…

756 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