1RENAME(1) User Commands RENAME(1)
2
3
4
6 rename - rename files
7
9 rename [options] expression replacement file...
10
12 rename will rename the specified files by replacing the first
13 occurrence of expression in their name by replacement.
14
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 -o, --no-overwrite
26 Do not overwrite existing files. When --symlink is active, do not
27 overwrite symlinks pointing to existing targets.
28
29 -i, --interactive
30 Ask before overwriting existing files.
31
32 -V, --version
33 Display version information and exit.
34
35 -h, --help
36 Display help text and exit.
37
39 The renaming has no safeguards by default or without any one of the
40 options --no-overwrite, --interactive or --no-act. If the user has
41 permission to rewrite file names, the command will perform the action
42 without any questions. For example, the result can be quite drastic
43 when the command is run as root in the /lib directory. Always make a
44 backup before running the command, unless you truly know what you are
45 doing.
46
48 As most standard utilities rename can be used with a terminal device
49 (tty in short) in canonical mode, where the line is buffered by the tty
50 and you press ENTER to validate the user input. If you put your tty in
51 cbreak mode however, rename requires only a single key press to answer
52 the prompt. To set cbreak mode, run for example:
53
54 sh -c 'stty -icanon min 1; "$0" "$@"; stty icanon' rename -i from to files
55
57 0
58 all requested rename operations were successful
59
60 1
61 all rename operations failed
62
63 2
64 some rename operations failed
65
66 4
67 nothing was renamed
68
69 64
70 unanticipated error occurred
71
73 Given the files foo1, ..., foo9, foo10, ..., foo278, the commands
74
75 rename foo foo00 foo?
76 rename foo foo0 foo??
77
78 will turn them into foo001, ..., foo009, foo010, ..., foo278. And
79
80 rename .htm .html *.htm
81
82 will fix the extension of your html files. Provide an empty string for
83 shortening:
84
85 rename '_with_long_name' '' file_with_long_name.*
86
87 will remove the substring in the filenames.
88
90 mv(1)
91
93 For bug reports, use the issue tracker at
94 https://github.com/karelzak/util-linux/issues.
95
97 The rename command is part of the util-linux package which can be
98 downloaded from Linux Kernel Archive
99 <https://www.kernel.org/pub/linux/utils/util-linux/>.
100
101
102
103util-linux 2.37.2 2021-08-16 RENAME(1)