1REN(1)                      General Commands Manual                     REN(1)
2
3
4

NAME

6       ren - rename multiple files
7

SYNOPSIS

9       ren [ -d | -k | -a ] [ -v ] [path/]search replacement
10

DESCRIPTION

12       Ren  renames  each file in the current directory (or in the path direc‐
13       tory, if specified) that matches  the  search  pattern;  each  matching
14       file's  new  name  is  given  by the replacement pattern.  The multiple
15       rename is performed safely, i.e. without  any  unexpected  deletion  of
16       files  due  to  collisions of replacement names with existing names, or
17       with other replacement names.  Also, all error checking is  done  prior
18       to doing any renames, so either all renames are done, or none.
19
20       The search pattern is a filename with embedded wildcards, i.e. * and ?,
21       which have their usual meanings of, respectively, matching  any  string
22       of characters, and matching any single character.  The replacement pat‐
23       tern is another filename with embedded wildcard indexes, each of  which
24       consists  of  the  character # followed by a digit from 1 to 9.  In the
25       new name of a matching file, the wildcard indexes are replaced  by  the
26       actual characters that matched the referenced wildcards in the original
27       filename.  Thus, if the search pattern is "abc*.*.*"  and the  replace‐
28       ment  pattern is "xyz#1.#3", then "abc.txt.doc" is renamed to "xyz.doc"
29       (since the first * matched "", the second matched "txt", and the  third
30       matched "doc").
31
32       Note  that  the  shell normally expands the wildcards * and ?, which in
33       the case of ren is undesirable.  Thus, in most cases it is necessary to
34       enclose  the  search pattern in quotes, e.g.  ren "*.a" #1.b.  To strip
35       any of the characters *, ?, and # of their special meaning to  ren,  as
36       when  the actual replacement name must contain the character #, precede
37       the special character with  \  (and  enclose  the  argument  in  qoutes
38       because of the shell).
39
40       Note  that  a path is not allowed in the replacement pattern.  Ren does
41       not allow moving  files  between  directories,  which  facilitates  the
42       safety checks next described.
43
44       When  any  two  matching files would have to be renamed to the same new
45       filename, ren detects the condition prior  to  doing  any  renames  and
46       aborts  with  an  error  message.   Ren also checks if any file deletes
47       would result from the rename, i.e. if  some  file1  would  have  to  be
48       renamed  to  file2,  and  file2  already exists and is not itself being
49       renamed.  (Here and below, "delete" really means "unlink".)  In such  a
50       case,  ren  asks  you  (by  reading  a line from standard input) if you
51       really wish file2 to be deleted.  If your answer is negative, file1  is
52       not renamed.
53
54       Ren safely performs chain renames, i.e. when file1 is renamed to file2,
55       file2 to file3, file3 to file4, etc, by doing the renames in the proper
56       order.   In  the  case that the chain is a cycle, i.e. filen is renamed
57       back to file1, ren breaks the cycle by using a temporary name.
58
59       Files beginning with . are not matched against the search pattern  (and
60       thus not renamed) unless the search pattern explicitly begins with '.'.
61       In any case, "." and ".." are never matched.
62
63       Options:
64
65       -v     (verbose): after each rename, the message "file1 -> file2 [(*)]"
66              appears  on the standard output.  The (*) appears in the case of
67              a deleting rename, i.e. when the old file2 is deleted.
68
69       -d,    -k, -a: suppress interrogation with regard to deleting  renames,
70              and:
71
72       -d     (delete): perform all deleting renames silently.
73
74       -k     (keep): perform no deleting renames.
75
76       -a     (abort):  if  any  deleting renames are detected, abort prior to
77              doing any renames.
78

SEE ALSO

80       mv(1)
81

AUTHOR

83       Vladimir Lanin
84       lanin@csd2.nyu.edu
85

BUGS

87       If the search pattern is not quoted, the shell expands  the  wildcards.
88       Ren  then  complains that there are too many arguments (if indeed there
89       are), but can not determine that the lack of quotes is the cause.
90
91
92
934th Berkeley Distribution        May 20, 1988                           REN(1)
Impressum