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
13       occurrence 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 made.
24
25       -a, --all
26           Replace all occurrences of expression rather than only the first
27           one.
28
29       -l, --last
30           Replace the last occurrence of expression rather than the first
31           one.
32
33       -o, --no-overwrite
34           Do not overwrite existing files. When --symlink is active, do not
35           overwrite symlinks pointing to existing targets.
36
37       -i, --interactive
38           Ask before overwriting existing files.
39
40       -h, --help
41           Display help text and exit.
42
43       -V, --version
44           Print version and exit.
45

WARNING

47       The renaming has no safeguards by default or without any one of the
48       options --no-overwrite, --interactive or --no-act. If the user has
49       permission to rewrite file names, the command will perform the action
50       without any questions. For example, the result can be quite drastic
51       when the command is run as root in the /lib directory. Always make a
52       backup before running the command, unless you truly know what you are
53       doing.
54

INTERACTIVE MODE

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

EXIT STATUS

65       0
66           all requested rename operations were successful
67
68       1
69           all rename operations failed
70
71       2
72           some rename operations failed
73
74       4
75           nothing was renamed
76
77       64
78           unanticipated error occurred
79

EXAMPLES

81       Given the files foo1, ..., foo9, foo10, ..., foo278, the commands
82
83           rename foo foo00 foo?
84           rename foo foo0 foo??
85
86       will turn them into foo001, ..., foo009, foo010, ..., foo278. And
87
88           rename .htm .html *.htm
89
90       will fix the extension of your html files. Provide an empty string for
91       shortening:
92
93           rename '_with_long_name' '' file_with_long_name.*
94
95       will remove the substring in the filenames.
96

SEE ALSO

98       mv(1)
99

REPORTING BUGS

101       For bug reports, use the issue tracker at
102       https://github.com/util-linux/util-linux/issues.
103

AVAILABILITY

105       The rename command is part of the util-linux package which can be
106       downloaded from Linux Kernel Archive
107       <https://www.kernel.org/pub/linux/utils/util-linux/>.
108
109
110
111util-linux 2.38                   2022-02-17                         RENAME(1)
Impressum