1RENAME(1)                        User Commands                       RENAME(1)
2
3
4

NAME

6       rename - rename files
7

SYNOPSIS

9       rename [options] expression replacement file...
10

DESCRIPTION

12       rename  will  rename  the specified files by replacing the first occur‐
13       rence of expression in their name by replacement.
14

OPTIONS

16       -s, --symlink
17              Do not rename a symlink but its target.
18
19       -v, --verbose
20              Show which files were renamed, if any.
21
22       -n, --no-act
23              Do not make any changes; add --verbose  to  see  what  would  be
24              made.
25
26       -o, --no-overwrite
27              Do  not  overwrite existing files.  When --symlink is active, do
28              not overwrite symlinks pointing to existing targets.
29
30       -i, --interactive
31              Ask before overwriting existing files.
32
33       -V, --version
34              Display version information and exit.
35
36       -h, --help
37              Display help text and exit.
38

EXAMPLES

40       Given the files foo1, ..., foo9, foo10, ..., foo278, the commands
41
42              rename foo foo00 foo?
43              rename foo foo0 foo??
44
45       will turn them into foo001, ..., foo009, foo010, ..., foo278.  And
46
47              rename .htm .html *.htm
48
49       will fix the extension of your html files.  Provide an empty string for
50       shortening:
51
52              rename '_with_long_name' '' file_with_long_name.*
53
54       will remove the substring in the filenames.
55

WARNING

57       The  renaming  has  no  safeguards by default or without any one of the
58       options --no-overwrite, --interactive or --no-act.   If  the  user  has
59       permission  to  rewrite file names, the command will perform the action
60       without any questions.  For example, the result can  be  quite  drastic
61       when  the  command is run as root in the /lib directory.  Always make a
62       backup before running the command, unless you truly know what  you  are
63       doing.
64

INTERACTIVE MODE

66       As  most  standard  utilities rename can be used with a terminal device
67       (tty in short) in canonical mode, where the line is buffered by the tty
68       and you press ENTER to validate the user input.  If you put your tty in
69       cbreak mode however, rename requires only a single key press to  answer
70       the prompt.  To set cbreak mode, run for example:
71
72              sh -c 'stty -icanon min 1; "$0" "$@"; stty icanon' rename -i from to files
73

EXIT STATUS

75              0      all requested rename operations were successful
76              1      all rename operations failed
77              2      some rename operations failed
78              4      nothing was renamed
79              64     unanticipated error occurred
80

SEE ALSO

82       mv(1)
83

AVAILABILITY

85       The  rename  command is part of the util-linux package and is available
86       from https://www.kernel.org/pub/linux/utils/util-linux/.
87
88
89
90util-linux                         June 2011                         RENAME(1)
Impressum