3 .\" Author: [see the "AUTHOR(S)" section]
4 .\" Generator: Asciidoctor 2.0.15
6 .\" Manual: User Commands
7 .\" Source: util-linux 2.38
10 .TH "RENAME" "1" "2022-02-17" "util\-linux 2.38" "User Commands"
28 . LINKSTYLE blue R < >
31 rename \- rename files
34 \fBrename\fP [options] \fIexpression replacement file\fP...
37 \fBrename\fP will rename the specified files by replacing the first occurrence of \fIexpression\fP in their name by \fIreplacement\fP.
40 \fB\-s\fP, \fB\-\-symlink\fP
42 Do not rename a symlink but its target.
45 \fB\-v\fP, \fB\-\-verbose\fP
47 Show which files were renamed, if any.
50 \fB\-n\fP, \fB\-\-no\-act\fP
52 Do not make any changes; add \fB\-\-verbose\fP to see what would be made.
55 \fB\-a\fP, \fB\-\-all\fP
57 Replace all occurrences of \fIexpression\fP rather than only the first one.
60 \fB\-l\fP, \fB\-\-last\fP
62 Replace the last occurrence of \fIexpression\fP rather than the first one.
65 \fB\-o\fP, \fB\-\-no\-overwrite\fP
67 Do not overwrite existing files. When \fB\-\-symlink\fP is active, do not overwrite symlinks pointing to existing targets.
70 \fB\-i\fP, \fB\-\-interactive\fP
72 Ask before overwriting existing files.
75 \fB\-h\fP, \fB\-\-help\fP
77 Display help text and exit.
80 \fB\-V\fP, \fB\-\-version\fP
82 Print version and exit.
86 The renaming has no safeguards by default or without any one of the options \fB\-\-no\-overwrite\fP, \fB\-\-interactive\fP or \fB\-\-no\-act\fP. If the user has permission to rewrite file names, the command will perform the action without any questions. For example, the result can be quite drastic when the command is run as root in the \fI/lib\fP directory. Always make a backup before running the command, unless you truly know what you are doing.
87 .SH "INTERACTIVE MODE"
89 As most standard utilities rename can be used with a terminal device (tty in short) in canonical mode, where the line is buffered by the tty and you press ENTER to validate the user input. If you put your tty in cbreak mode however, rename requires only a single key press to answer the prompt. To set cbreak mode, run for example:
94 sh \-c \(aqstty \-icanon min 1; "$0" "$@"; stty icanon\(aq rename \-i from to files
102 all requested rename operations were successful
107 all rename operations failed
112 some rename operations failed
122 unanticipated error occurred
126 Given the files \fIfoo1\fP, ..., \fIfoo9\fP, \fIfoo10\fP, ..., \fIfoo278\fP, the commands
131 rename foo foo00 foo?
132 rename foo foo0 foo??
137 will turn them into \fIfoo001\fP, ..., \fIfoo009\fP, \fIfoo010\fP, ..., \fIfoo278\fP. And
142 rename .htm .html *.htm
147 will fix the extension of your html files. Provide an empty string for shortening:
152 rename \(aq_with_long_name\(aq \(aq\(aq file_with_long_name.*
157 will remove the substring in the filenames.
163 For bug reports, use the issue tracker at \c
164 .URL "https://github.com/util\-linux/util\-linux/issues" "" "."
167 The \fBrename\fP command is part of the util\-linux package which can be downloaded from \c
168 .URL "https://www.kernel.org/pub/linux/utils/util\-linux/" "Linux Kernel Archive" "."