1 .\" Written by Andries E. Brouwer (aeb@cwi.nl)
2 .\" Placed in the public domain
4 .TH RENAME 1 "June 2011" "util-linux" "User Commands"
10 .IR "expression replacement file" ...
13 will rename the specified files by replacing the first occurrence of
19 .BR \-s , " \-\-symlink"
20 Do not rename a symlink but its target.
22 .BR \-v , " \-\-verbose"
23 Show which files were renamed, if any.
25 .BR \-n , " \-\-no\-act"
26 Do not make any changes; add
28 to see what would be made.
30 .BR \-o , " \-\-no\-overwrite"
31 Do not overwrite existing files. When
33 is active, do not overwrite symlinks pointing to existing targets.
35 .BR \-i , " \-\-interactive"
36 Ask before overwriting existing files.
38 .BR \-V , " \-\-version"
39 Display version information and exit.
42 Display help text and exit.
44 The renaming has no safeguards by default or without any one of the options
45 .B \-\-no-overwrite\fR,
50 permission to rewrite file names, the command will perform the action without
51 any questions. For example, the result can be quite drastic when the command
52 is run as root in the /lib directory. Always make a backup before running the
53 command, unless you truly know what you are doing.
55 As most standard utilities rename can be used with a terminal device (tty in
56 short) in canonical mode, where the line is buffered by the tty and you press
57 ENTER to validate the user input. If you put your tty in cbreak mode however,
58 rename requires only a single key press to answer the prompt. To set cbreak
59 mode, run for example:
63 sh \-c 'stty \-icanon min 1; "$0" "$@"; stty icanon' rename \-i from to files
72 all requested rename operations were successful
75 all rename operations failed
78 some rename operations failed
84 unanticipated error occurred
89 .IR foo1 ", ..., " foo9 ", " foo10 ", ..., " foo278 ,
100 .IR foo001 ", ..., " foo009 ", " foo010 ", ..., " foo278 .
105 rename .htm .html *.htm
109 will fix the extension of your html files.
110 Provide an empty string for shortening:
114 rename '_with_long_name' '' file_with_long_name.*
118 will remove the substring in the filenames.
122 The rename command is part of the util-linux package and is available from
123 https://www.kernel.org/pub/linux/utils/util-linux/.