XXCOPY
[ Back to Table of Contents ] [ << ] [ >> ]

XXCOPY TECHNICAL BULLETIN #17


From:    Kan Yabumoto           tech@xxcopy.com
To:      XXCOPY user
Subject: Selecting files by file date amd time using XXCOPY
Date:    2001-02-23  (revised)
===============================================================================

Introduction

  The filedate value offers yet another trait to select files for
  various file management operations.  Microsoft's XCOPY allows you
  to specify a cut-off date to select some recently created files.
  Our XXCOPY, on the other hand, seizes the opportunity with respect
  to the filedate (and time) to a much greater extent for qualifying
  files for a large collection of functions.

  While the fundamental elements of filedate-related operations are
  quite simple, the total number of variations may be daunting
  to some users.  So to ease the pain of memorizing the details,
  here in this article, simpler things are presented first, followed
  by more complicated aspects.


The file date/time related XXCOPY switches.

  The ten basic filetime switches fall into either of the two groups:

    Comparison to the reference file (newer/older/same/different)

        /DA,  /DB,  /DS,  /DX         ; newer, older, same, different

    Relative and Absolute date specifiers (you give the range of date)

        /DA#n,    /DB#n,    /DO#n     ; as how many days ago from today
        /DA:date, /DB:date, /DO:date  ; date specified as yyyy-mm-dd


Comparing the filetime of two files

  The filetime comparison switches are used mainly for directory
  synchronization and various backup operations based on file time.
  Therefore, in all cases, the file time comparison is made on a
  pair of files; one from the first (source) directory, and the other
  from the second (destination ,or sometimes reference) directory.

  In this case, the pair of files are compared not only by the
  filedate, but also by the file time to the finest value (hour,
  minute, and second) (see below for /FF for details).  Since the
  comparison is made on the file time value which are stored in
  the respective directory, the XXCOPY user does not specify the
  value and therefore, the command syntax for these switches are
  the simplest; /D, /DA, /DB, /DX, /DS without any user-specified
  parameter.

     /D   Same as /DA
     /DA  Copies newer files and brand new files.
     /DB  Copies older files and brand new files.
     /DX  Copies different-date files only.
     /DS  Copies same date/time files only.


Testing file's date against a user-specified date range

  Unlike the file time comparison method presented in the preceding
  section, XXCOPY allows you to select files based on the filedate
  associated with each file which are expressed in either the relative
  date (how many days ago from today), or the absolute date (specified
  in year, month and day).  For this feature, XXCOPY maintains one
  or two dates to qualify files for file management operations.

     "A-date value" for On-or-After date  (entered by /DA: or /DA#)
     "B-date value" for On-or-Before date (entered by /DB: or /DA#)


  The relative date specifiers

      System administrators often refer to a group of files by the age
      of the files for backup operations.  One of the most natural ways
      of specifying them is the file age measured in days (relative to
      the current date).

      /DA#<n>  Copies files that were changed on or after  <n> days ago.
      /DB#<n>  Copies files that were changed on or before <n> days ago.


      Examples of command lines using the relative date:

        XXCOPY  src  dst  /DA#60            // After 60 days ago
        XXCOPY  src  dst  /DB#30            // Before 30 days ago
        XXCOPY  src  dst  /DA#60  /DB#30    // files with age of 30-60 days
        XXCOPY  src  dst  /D#100            // same as /DA#100

      As you can see from the examples, you may specify only one of
      the "A-date value" and "B-date value" or both.  If you specify
      only one date value, then the other end is open-ended.

      Note that the file age is measured by the number of days starting
      0 (zero) as the value for files made today, 1 (one) for files made
      yesterday, and so on.

      When you specify both the "A-date value" and "B-date value", the
      date range you specify may be used for an inclusive selection or
      exclusive selection, depending on which of the two values are newer.
      The following examples illustrate this point more clearly.

        XXCOPY  src  dst  /DA#60  /DB#30    // files with age of 30-60 days
        XXCOPY  src  dst  /DB#60  /DA#30    // age >= 60 or age <= 30

        Here, two same date values are specified for the opposite
        /DA: and /DB: switches.  The first example is the most common
        case where the two dates specify the beginning and the end of
        a single period.  On the other hand, the second example shows
        different case where the two date are applied toward the
        opposite direction in the timeline which in effect excludes
        files in the excluded period (files with age 31-59 days are
        NOT selected) --- such a case is accepted as a valid command.

      Note that when the age is referred to by the number of days,
      it is not measured by the multiple of 24 hours.  Rather, the 0th day
      (today) began at midnight today to take care any fraction of today.
      That is, /DA#0 specifies the files made on or after midnight today.
      This scheme allows the cut-off time to be midnight of each day.


  The relative time specifiers

      The relative time specifier adds few more twists to the relative
      date specifier.  In the /DA#n  /DB#n or /DO#n switches, when the
      age value n is given as a number without a suffix, the age will
      be measured by number of the days.  This is probably most common
      usage.  But, you may add a single-letter suffix (D, H, M, or S)
      to the value (for Days, Hours, Minutes or Seconds, respectively).

      Examples:

        XXCOPY  src /S /LDT /DA#30M   // list files made within 30 min.
        XXCOPY  src dst /s  /DA#24H   // copy files made within 24 hours
        XXCOPY  src dst /s  /DA#0     // copy files made today (since midnight)


  The absolute date specifiers

      Since we reference dates by year, month and day quite often in
      our day-to-day lives, it is also very natural for us to specify
      the file time as such.

      /DA:<date> Copies files that were changed on or after the specified date.
      /DB:<date> Copies files that were changed on or before the specified date.


      Examples of command lines using the absolute date:

        XXCOPY  src  dst  /DA:2000-1-1
        XXCOPY  src  dst  /DB:1999-12-31
        XXCOPY  src  dst  /DA:1998-1-1 /DB:2000-8-31
        XXCOPY  src  dst  /D:1998-1-1              // same as /DA#1998-1-1


  Now, you already know the essential mechanism of XXCOPY which controls
  file selection based on the filedate.  Nearly all of the remaining
  discussion is for various shortcuts and clarifications of details.


The "O-date value" for the same parameter

  When the "A-date value" is the same as the "B-date value" (to specify
  a particular date), you may use the third way, the "O-date value" to
  combine the two into one parameter.
  You can use the "O-date value" (On the date) whenever the "A-date value"
  and the "B-date value" are the same.  (Here, the letter O (oh, not zero)
  is shown in lowercase (o) to avoid confusion.)

      The following two commands are equivalent:

        XXCOPY  src  dst  /DA:2000-5-1 /DB:2000-5-1
        XXCOPY  src  dst  /Do:2000-5-1

     It also applies to the relative date specifier.  The following
     two commands are equivalent.

     XXCOPY  src  dst  /DA#80 /DB#80
     XXCOPY  src  dst  /Do#80


Shortcut for Today and Yesterday

  One of the most common date used with XXCOPY is the current date
  (today) and one day earlier (yesterday).  So, we assign the dot (.)
  parameter as a shortcut for today's date for the /DA and /Do switches,
  and as a shortcut for yesterday's date for the /DB switch.

      /DB:. or /DB#.  specify filedate date is Yesterday or earlier.
      /DA:. or /DA#.  specify filedate that is today or later.
      /Do:. or /Do#.  specify filedate that is today only.


Partial date specifiers

  You may specify a month by omitting the day-of-the-month value.  If
  only two numbers are given, one must be a 4-digit year value.  The
  following command lines all specify the entire month of February, 2000.
  The "B-date value" in this context specifies the last day of the
  month, and the "O-date value" in this context specify the whole month.

     XXCOPY  src  dst  /DA:2000-2-1 /DB:2000-2-29
     XXCOPY  src  dst  /DA:2000-2   /DB:2000-2
     XXCOPY  src  dst  /Do:2000-2

  Similarly, you may specify the filedate by the year.
  The following three cases are equivalent.

     XXCOPY  src  dst  /DA:2000-1-1 /DB:2000-12-31
     XXCOPY  src  dst  /DA:2000     /DB:2000
     XXCOPY  src  dst  /Do:2000

  The partial date specifiers that are shown so far are for the cases
  of the whole month and the whole year.  But, the usage of partial date
  specifier is not limited to such cases.  When it is used for the
  /DA parameter, the partial date value specifies the first day of
  the month/year.  When it is used for the /DB parameter, it denotes
  the end of the month/year.  And, when it is used for the /Do
  parameter, it selects the whole month/year.  Here are some examples.

     XXCOPY  src  dst  /DA:1999-4           // same as /DA:1999-04-01
     XXCOPY  src  dst  /DA:1998             // same as /DB:1998-01-01

     XXCOPY  src  dst  /DB:2000-5           // same as /DB:2000-05-31
     XXCOPY  src  dst  /DB:1998             // same as /DB:1998-12-31

     XXCOPY  src  dst  /Do:2000-2           // the month of Feb, 2000
     XXCOPY  src  dst  /Do:2000             // the whole year 2000

     XXCOPY  src  dst  /DA:1998-4 /DB:1999  // /DA:1998-04-01 /DB:1999-12-31


Odd cases:

   The relative and absolute date specifiers can be mixed in a command.
   Although most users avoid mixing the two types of expressing the
   date value, there is nothing inherently wrong about using both the
   relative and absolute date specifiers.

       XXCOPY  src  dst  /DA:2000-1-1  /DB#7

       This example specifies files that are at least one week old
       which are made in the year 2000.

   You cannot specify two periods in timeline in one XXCOPY command.
   That is, XXCOPY maintains one "A-date value" and one "B-date value".
   If you specify two A-date values, the first such value will be
   discarded.


International conventions

   We endorse the ISO-8601 convention (DMXXTB #025) which denotes the date/time value in
   the most logical order.  But, XXCOPY also accepts other conventions
   if the date value is unambiguously specified.  It allows one of the
   three (ISO, US and EU) conventions to be used for an absolute date
   specifier as long as it is value is unambiguous.  For example,

       /DA:2000-01-02      // ISO  the first value is larger than 1970
       /DA:0-1-2           // ISO  0 (for 2000) cannot be for month or day
       /DA:12-13-2000      // US   the value 13 cannot be a month value
       /DA:01-13-01        // US   the only one to have 13 in the middle
       /DA:13-10-2000      // EU   the value 13 cannot be a month value

    This applies to the partial date specifiers.  Therefore, both
    /DA:2000-03 and /DA:03-2000 are accepted as equally unambiguous.

    But, when there are more than one way to interpret the date value,
    the system's date format setting will be used to resolve ambiguity.
    The following date specifiers are such ambiguous cases and we
    suggest you avoid these cases.

       /DA:1-2-3           // can be ISO, US, or EU;  pretty bad
       /DA:12-12-12        // can be ISO, US, or EU
       /DA:1-2-2000        // can be US or EU
       /DA:11-12-13        // can be ISO, US, or EU
       /DA:13-12-11        // can be ISO, or EU

    I hope by now, you are convinced of the superiority of the ISO
    notation which also gives you the convenience of easy sorting.

    In the case of the partial date specifier, the year value must
    always be in a full 4-digit value.  In this case, the order of
    the year and month value can be switched without causing any
    ambiguity.  For example;

       /DA:2000-01         // partial ISO notation
       /DA:12-1999         // US/EU


File time-related switches

  All file time related functions can be further modified by various
  switches to meet your specific needs which may be different from
  the majority users.


  /FW, /FA, /FC (Last-Written, Last-Accessed, Created)

    Under normal circumstances, the file date/time XXCOPY uses is the
    time the file was last written (the commonly used file time value,
    /FW as the default), it can be substituted by the last-accessed
    time (/FA) or file creation time (/FC).

  /FL, /FU (Local time, UTC time)

    The commonly used file time is expressed by the local time (/FL
    as the default).  However, in networking environment, it may be
    more convenient for some users to enter the file time using the
    UTC time (/FU) which is also known as GMT (Greenwich Mean Time).

  /FF (Fuzzy Filetime)

    When file time is compared against one another in a mixed OS
    environment, the granularity of the file time stamp (which is
    usually set by the particular file system) may cause problems.
    For example, the FAT based file systems (FAT12, FAT16, FAT32)
    uses file time which is measured by two second interval whereas
    unix-based file system uses one second interval. The NTFS uses
    much finer filetime.  The /FF switch forces XXCOPY to ignore
    the filetime difference within plus/minus 2 seconds so that
    a timestamp-based incremental backup between an NTFS volume and
    a FAT volume (or more broadly beteen different file systems)
    without selecting all files due to the inherent difference in
    the timestamp granularity.



© Copyright 2016 Pixelab All rights reserved.

[ XXCOPY Home ] [ Table of Contents ] [ << ] [ >> ]

Join the XXCOPY group