home *** CD-ROM | disk | FTP | other *** search
/ Black Box 4 / BlackBox.cdr / fileutil / mmv10exe.arj / MMV.MAN < prev    next >
Encoding:
Text File  |  1989-11-22  |  16.0 KB  |  463 lines

  1.  
  2.  
  3.  
  4. MMV(1)                 Programmer's Manual                 MMV(1)
  5.  
  6.  
  7.  
  8. NAME
  9.      mmv - move/copy/append multiple files by wildcard patterns
  10.  
  11. SYNOPSIS
  12.      mmv [-m|x|r|c|o|a|z] [-h] [-d|p] [-g|t] [-v|n] [from to]
  13.      mmvpatch [executable]
  14.  
  15. DESCRIPTION
  16.      _M_m_v moves (or copies, or appends, as specified) each source
  17.      file matching a _f_r_o_m pattern to the target name specified by
  18.      the _t_o pattern.  This multiple action is performed safely,
  19.      i.e. without any unexpected deletion of files due to colli-
  20.      sions of target names with existing filenames or with other
  21.      target names.  Furthermore, before doing anything, _m_m_v
  22.      attempts to detect any errors that would result from the
  23.      entire set of actions specified and gives the user the
  24.      choice of either proceeding by avoiding the offending parts
  25.      or aborting.
  26.  
  27.                            The Task Options
  28.  
  29.      Whether _m_m_v moves, copies, or appends is governed by the
  30.      first set of options given above.  If none of these are
  31.      specified, a default (patchable by _m_m_v_p_a_t_c_h, and initially
  32.      -x) determines the task.
  33.  
  34.      The task option choices are:
  35.  
  36.      -m : move source file to target name.  Both must be on the
  37.           same device.  Will not move directories.
  38.  
  39.      -x : same as -m, except cross-device moves are done by copy-
  40.           ing, then deleting source.  When copying, sets the
  41.           attributes and file modification time of the target
  42.           file to that of the source file.
  43.  
  44.      -r : rename source file or directory to target name.  The
  45.           target name must not include a path: the file remains
  46.           in the same directory in all cases.  This option is the
  47.           only way of renaming directories under _m_m_v.  It is only
  48.           available under DOS version 3.0 or higher.
  49.  
  50.      -c : copy source file to target name.  Sets the file modifi-
  51.           cation time and attributes of the target file to that
  52.           of the source file, regardless of whether the target
  53.           file already exists.  Chains and cycles (to be
  54.           explained below) are not allowed.
  55.  
  56.      -o : overwrite target name with source file.  If target file
  57.           exists, its attributes are left unchanged.  If not, it
  58.           is created with ordinary attributes unrelated to the
  59.           source file's attributes.  In either case, the file
  60.  
  61.  
  62.  
  63. Printed 11/21/89    November 20, 1989 (v1.0)                    1
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70. MMV(1)                 Programmer's Manual                 MMV(1)
  71.  
  72.  
  73.  
  74.           modification time is set to the current time.
  75.  
  76.      -a : append contents of source file to target name.  Target
  77.           file modification time is set to the current time.  If
  78.           target file does not exist, it is created with attri-
  79.           butes set as under -o.  Unlike all other options, -a
  80.           allows multiple source files to have the same target
  81.           name, e.g. "mmv -a *.c big" will append all ".c" files
  82.           to "big".  Chains and cycles are also allowed, so "mmv
  83.           -a f f" will double up "f".
  84.  
  85.      -z : same as -a, but if the target file exists, and its last
  86.           character is a ^Z, and the source file is not empty,
  87.           this ^Z is truncated before doing the append.
  88.  
  89.      Only one of these option may be given, and it applies to all
  90.      matching files.  Remaining options need not be given
  91.      separately, i.e. "mmv -mk" is allowed.
  92.  
  93.                         Multiple Pattern Pairs
  94.  
  95.      Multiple _f_r_o_m -- _t_o pattern pairs may be specified by omit-
  96.      ting the pattern pair on the command line, and entering them
  97.      on the standard input, one pair per line.  (If a pattern
  98.      pair is given on the command line, the standard input is not
  99.      read.) Thus,
  100.  
  101.         mmv
  102.         a b
  103.         c d
  104.  
  105.      would rename "a" to "b" and "c" to "d".  If a file can be
  106.      matched to several of the given _f_r_o_m patterns, the _t_o pat-
  107.      tern of the first matching pair is used.  Thus,
  108.  
  109.         mmv
  110.         a b
  111.         a c
  112.  
  113.      would give the error message "a -> c : no match" because
  114.      file "a" (even if it exists) was already matched by the
  115.      first pattern pair.
  116.  
  117.                            The _F_r_o_m Pattern
  118.  
  119.      The _f_r_o_m pattern is a filename with embedded wildcards: '*',
  120.      '?', '['...']', '!',  and ';'.  The first three have their
  121.      usual _s_h(1) meanings of, respectively, matching any string
  122.      of characters, matching any single character, and matching
  123.      any one of a set of characters.
  124.  
  125.  
  126.  
  127.  
  128.  
  129. Printed 11/21/89    November 20, 1989 (v1.0)                    2
  130.  
  131.  
  132.  
  133.  
  134.  
  135.  
  136. MMV(1)                 Programmer's Manual                 MMV(1)
  137.  
  138.  
  139.  
  140.      Between the '[' and ']', a range from character 'a' through
  141.      character 'z' is specified with "a-z".  The set of matching
  142.      characters can be negated by inserting a '^' after the '['.
  143.      Thus, "[^b-e2-5_]" will match any character but 'b' through
  144.      'e', '2' through '5', and '_'.
  145.  
  146.      Unlike DOS wildcards, all mmv wildcards (except for cases
  147.      listed below) can occur anywhere in the pattern, whether
  148.      preceding or following explicit characters or other wild-
  149.      cards.  For example, the pattern "*z\foo.bar" will search
  150.      for files named "foo.bar" in all subdirectories whose names
  151.      end in 'z'.  However, no wildcards can occur in the drive
  152.      letter.
  153.  
  154.      The character '.' is not matched by any of '*', '?', or
  155.      '['...']'.  Thus, the pattern "*" will only match files with
  156.      a null extension.  To save yourself some typing, use the '!'
  157.      wildcard instead, which matches the same as "*.*", except it
  158.      is assigned only one wildcard index (see below).  Thus, both
  159.      "f!" and "f*.*" will match all of "f", "f.ext", "foo", and
  160.      "foo.ext", while "f*" will match only the first and the
  161.      third.
  162.  
  163.      Note that paths are allowed in the patterns, and wildcards
  164.      may be intermingled with slashes arbitrarily.  The ';' wild-
  165.      card is useful for matching files at any depth in the direc-
  166.      tory tree.  It matches the same as "*\" repeated any number
  167.      of times, including zero, and can only occur either at the
  168.      beginning of the pattern or following a '\'.  Thus ";*.c"
  169.      will match all ".c" files in or below the current directory,
  170.      while "\;*.c" will match them anywhere on the file system.
  171.  
  172.      Since matching a directory under a task option other than -r
  173.      or -s would result in an error, tasks other than -r and -s
  174.      match directories only against completely explicit _f_r_o_m pat-
  175.      terns (i.e. not containing wildcards).  Under -r and -s,
  176.      this applies only to "." and "..".
  177.  
  178.      Hidden and system files are also only matched against com-
  179.      pletely explicit _f_r_o_m patterns.   However, if -h is speci-
  180.      fied, they are matched normally.
  181.  
  182.                             The _T_o Pattern
  183.  
  184.      The _t_o pattern is a filename with embedded _w_i_l_d_c_a_r_d _i_n_d_e_x_e_s,
  185.      where an index consists of the character '#' followed by a
  186.      string of digits.  When a source file matches a _f_r_o_m pat-
  187.      tern, a target name for the file is constructed out of the
  188.      _t_o pattern by replacing the wildcard indexes by the actual
  189.      characters that matched the referenced wildcards in the
  190.      source name.  Thus, if the _f_r_o_m pattern is "abc*.*" and the
  191.      _t_o pattern is "xyz#2.#1", then "abc.txt" is targeted to
  192.  
  193.  
  194.  
  195. Printed 11/21/89    November 20, 1989 (v1.0)                    3
  196.  
  197.  
  198.  
  199.  
  200.  
  201.  
  202. MMV(1)                 Programmer's Manual                 MMV(1)
  203.  
  204.  
  205.  
  206.      "xyztxt.".  (The first '*' matched "", and the second
  207.      matched "txt".) Similarly, for the pattern pair ";*.[clp]"
  208.      -> "#1#3\#2", "foo1\foo2\prog.c" is targeted to
  209.      "foo1\foo2\c\prog".  Note that there is no '\' following the
  210.      "#1" in the _t_o pattern, since the string matched by any ';'
  211.      is always either empty or ends in a '\'.  In this case, it
  212.      matches "foo1\foo2\".
  213.  
  214.      For all task options other than -r, if the target name is a
  215.      directory, the real target name is formed by appending a '\'
  216.      followed by the last component of the source file name.  For
  217.      example, "mmv dir1\a dir2" will, if "dir2" is indeed a
  218.      directory, actually move "dir1\a" to "dir2\a".  However, if
  219.      "dir2\a" already exists and is itself a directory, this is
  220.      considered an error.
  221.  
  222.      To strip any character (e.g. '*', '?', or '#') of its spe-
  223.      cial meaning to _m_m_v, as when the actual replacement name
  224.      must contain the character '#', precede the special charac-
  225.      ter with a single quote (').   This also works to terminate
  226.      a wildcard index when it has to be followed by a digit in
  227.      the filename, e.g. "a#1'1".
  228.  
  229.                           Chains and Cycles
  230.  
  231.      A chain is a sequence of specified actions where the target
  232.      name of one action refers to the source file of another
  233.      action.  For example,
  234.  
  235.      mmv
  236.      a b
  237.      b c
  238.  
  239.      specifies the chain "a" -> "b" -> "c".  A cycle is a chain
  240.      where the last target name refers back to the first source
  241.      file, e.g. "mmv a a".  _M_m_v detects chains and cycles regard-
  242.      less of the order in which their constituent actions are
  243.      actually given.  Where allowed, i.e. in moving, renaming,
  244.      and appending files, chains and cycles are handled grace-
  245.      fully, by performing them in the proper order.  Cycles are
  246.      broken by first renaming one of the files to a temporary
  247.      name (or just remembering its original size when doing
  248.      appends).
  249.  
  250.                        Collisions and Deletions
  251.  
  252.      When any two or more matching files would have to be moved
  253.      or copied to the same target filename, _m_m_v detects the con-
  254.      dition as an error before performing any actions.  Further-
  255.      more, _m_m_v checks if any of its actions will result in the
  256.      destruction of existing files.  If the -d (delete) option is
  257.      specified, all file deletions or overwrites are done
  258.  
  259.  
  260.  
  261. Printed 11/21/89    November 20, 1989 (v1.0)                    4
  262.  
  263.  
  264.  
  265.  
  266.  
  267.  
  268. MMV(1)                 Programmer's Manual                 MMV(1)
  269.  
  270.  
  271.  
  272.      silently.  Under -p (protect), all deletions or overwrites
  273.      (except those specified with "(*)" on the standard input,
  274.      see below) are treated as errors.  And if neither option is
  275.      specified, the user is queried about each deletion or
  276.      overwrite separately.  (A new stream to "\dev\con" is used
  277.      for all interactive queries, not the standard input.)
  278.  
  279.                             Error Handling
  280.  
  281.      Whenever any error in the user's action specifications is
  282.      detected, an error message is given on the standard output,
  283.      and _m_m_v proceeds to check the rest of the specified actions.
  284.      Once all errors are detected, _m_m_v queries the user whether
  285.      he wishes to continue by avoiding the erroneous actions or
  286.      to abort altogether.  This and all other queries may be
  287.      avoided by specifying either the -g (go) or -t (terminate)
  288.      option.  The former will resolve all difficulties by avoid-
  289.      ing the erroneous actions; the latter will abort _m_m_v if any
  290.      errors are detected.  Specifying either of them defaults _m_m_v
  291.      to -p, unless -d is specified (see above).  Thus, -g and -t
  292.      are most useful when running _m_m_v in the background or in a
  293.      shell script, when interactive queries are undesirable.
  294.  
  295.                                Reports
  296.  
  297.      Once the actions to be performed are determined, _m_m_v per-
  298.      forms them silently, unless either the -v (verbose) or -n
  299.      (no-execute) option is specified.  The former causes _m_m_v to
  300.      report each performed action on the standard output as
  301.  
  302.      a -> b : done.
  303.  
  304.      Here, "a" and "b" would be replaced by the source and target
  305.      names, respectively.  If the action deletes the old target,
  306.      a "(*)" is inserted after the the target name.  Also, the
  307.      "->" symbol is modified when a cycle has to be broken: the
  308.      '>' is changed to a '^' on the action prior to which the old
  309.      target is renamed to a temporary, and the '-' is changed to
  310.      a '=' on the action where the temporary is used.
  311.  
  312.      Under -n, none of the actions are performed, but messages
  313.      like the above are printed on the standard output with the
  314.      ": done." omitted.
  315.  
  316.      The output generated by -n can (after editing, if desired)
  317.      be fed back to _m_m_v on the standard input (by omitting the
  318.      _f_r_o_m -- _t_o pair on the _m_m_v command line).  To facilitate
  319.      this, _m_m_v ignores lines on the standard input that look like
  320.      its own error and "done" messages, as well as all lines
  321.      beginning with white space, and will accept pattern pairs
  322.      with or without the intervening "->" (or "-^", "=>", or
  323.      "=^").  Lines with "(*)" after the target pattern have the
  324.  
  325.  
  326.  
  327. Printed 11/21/89    November 20, 1989 (v1.0)                    5
  328.  
  329.  
  330.  
  331.  
  332.  
  333.  
  334. MMV(1)                 Programmer's Manual                 MMV(1)
  335.  
  336.  
  337.  
  338.      effect of enabling -d for the files matching this pattern
  339.      only, so that such deletions are done silently.  When feed-
  340.      ing _m_m_v its own output, one must remember to specify again
  341.      the task option (if any) originally used to generate it.
  342.  
  343.      Although _m_m_v attempts to predict all mishaps prior to per-
  344.      forming any specified actions, accidents may happen.  For
  345.      example, _m_m_v does not check for adequate free space when
  346.      copying.  Thus, despite all efforts, it is still possible
  347.      for an action to fail after some others have already been
  348.      done.  To make recovery as easy as possible, _m_m_v reports
  349.      which actions have already been done and which are still to
  350.      be performed after such a failure occurs.  It then aborts,
  351.      not attempting to do anything else.  Once the user has
  352.      cleared up the problem, he can feed this report back to _m_m_v
  353.      on the standard input to have it complete the task.  (The
  354.      user is queried for a file name to dump this report if the
  355.      standard output has not been redirected.)
  356.  
  357.                                _M_m_v_p_a_t_c_h
  358.  
  359.      You can customize a copy of _m_m_v via the _m_m_v_p_a_t_c_h utility.
  360.      If you wish to change the default task option, run _m_m_v_p_a_t_c_h
  361.      on a copy of _m_m_v named as follows:
  362.  
  363.           -x, -m, -r          mmv.exe
  364.           -c, -o              mcp.exe
  365.           -a, -z              mad.exe
  366.  
  367.      _M_m_v_p_a_t_c_h also determines the best way to uniquely identify
  368.      directories.  As distributed, _m_m_v is set to use a method
  369.      that is guaranteed to work the same way for all versions of
  370.      DOS, but is both slow and unable to correctly handle drives
  371.      affected by the _j_o_i_n and _s_u_b_s_t DOS commands.  Alternatively,
  372.      there is a method that is fast and correct, but uses an
  373.      undocumented DOS feature that may not work properly under
  374.      all versions of DOS.  (However, 2.0 and 3.3 are known to
  375.      work.) _M_m_v does _n_o_t determine the best method to use on your
  376.      system at run-time since this is too slow.  The choice is
  377.      left to _m_m_v_p_a_t_c_h, which determines if the fast method works,
  378.      but also allows you to return to the slow method.
  379.  
  380. EXIT STATUS
  381.      _M_m_v exits with status 1 if it aborts before doing anything,
  382.      with status 2 if it aborts due to failure after completing
  383.      some of the actions, and with status 0 otherwise.
  384.  
  385. AUTHOR
  386.      Vladimir Lanin
  387.      lanin@csd2.nyu.edu
  388.  
  389.  
  390.  
  391.  
  392.  
  393. Printed 11/21/89    November 20, 1989 (v1.0)                    6
  394.  
  395.  
  396.  
  397.  
  398.  
  399.  
  400. MMV(1)                 Programmer's Manual                 MMV(1)
  401.  
  402.  
  403.  
  404. BUGS
  405.      _m_m_v refuses to move or create directories.
  406.  
  407.  
  408.  
  409.  
  410.  
  411.  
  412.  
  413.  
  414.  
  415.  
  416.  
  417.  
  418.  
  419.  
  420.  
  421.  
  422.  
  423.  
  424.  
  425.  
  426.  
  427.  
  428.  
  429.  
  430.  
  431.  
  432.  
  433.  
  434.  
  435.  
  436.  
  437.  
  438.  
  439.  
  440.  
  441.  
  442.  
  443.  
  444.  
  445.  
  446.  
  447.  
  448.  
  449.  
  450.  
  451.  
  452.  
  453.  
  454.  
  455.  
  456.  
  457.  
  458.  
  459. Printed 11/21/89    November 20, 1989 (v1.0)                    7
  460.  
  461.  
  462.  
  463.