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 occur‐
13 rence 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
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
40 The renaming has no safeguards by default or without any one of the
41 options --no-overwrite, --interactive or --no-act. If the user has
42 permission to rewrite file names, the command will perform the action
43 without any questions. For example, the result can be quite drastic
44 when the command is run as root in the /lib directory. Always make a
45 backup before running the command, unless you truly know what you are
46 doing.
47
49 As most standard utilities rename can be used with a terminal device
50 (tty in short) in canonical mode, where the line is buffered by the tty
51 and you press ENTER to validate the user input. If you put your tty in
52 cbreak mode however, rename requires only a single key press to answer
53 the prompt. To set cbreak mode, run for example:
54
55 sh -c 'stty -icanon min 1; "$0" "$@"; stty icanon' rename -i from to files
56
58 0 all requested rename operations were successful
59 1 all rename operations failed
60 2 some rename operations failed
61 4 nothing was renamed
62 64 unanticipated error occurred
63
65 Given the files foo1, ..., foo9, foo10, ..., foo278, the commands
66
67 rename foo foo00 foo?
68 rename foo foo0 foo??
69
70 will turn them into foo001, ..., foo009, foo010, ..., foo278. And
71
72 rename .htm .html *.htm
73
74 will fix the extension of your html files. Provide an empty string for
75 shortening:
76
77 rename '_with_long_name' '' file_with_long_name.*
78
79 will remove the substring in the filenames.
80
82 mv(1)
83
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)