]> git.ipfire.org Git - thirdparty/util-linux.git/blob - misc-utils/rename.1.adoc
build-sys: make man pages location independent
[thirdparty/util-linux.git] / misc-utils / rename.1.adoc
1 //po4a: entry man manual
2 // Written by Andries E. Brouwer (aeb@cwi.nl)
3 // Placed in the public domain
4 = rename(1)
5 :doctype: manpage
6 :man manual: User Commands
7 :man source: util-linux {release-version}
8 :page-layout: base
9 :command: rename
10
11 == NAME
12
13 rename - rename files
14
15 == SYNOPSIS
16
17 *rename* [options] _expression replacement file_...
18
19 == DESCRIPTION
20
21 *rename* will rename the specified files by replacing the first occurrence of _expression_ in their name by _replacement_.
22
23 == OPTIONS
24
25 *-s*, *--symlink*::
26 Do not rename a symlink but its target.
27
28 *-v*, *--verbose*::
29 Show which files were renamed, if any.
30
31 *-n*, *--no-act*::
32 Do not make any changes; add *--verbose* to see what would be made.
33
34 *-o*, *--no-overwrite*::
35 Do not overwrite existing files. When *--symlink* is active, do not overwrite symlinks pointing to existing targets.
36
37 *-i*, *--interactive*::
38 Ask before overwriting existing files.
39
40 *-V*, *--version*::
41 Display version information and exit.
42
43 *-h*, *--help*::
44 Display help text and exit.
45
46 == WARNING
47
48 The renaming has no safeguards by default or without any one of the options *--no-overwrite*, *--interactive* or *--no-act*. 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 _/lib_ directory. Always make a backup before running the command, unless you truly know what you are doing.
49
50 == INTERACTIVE MODE
51
52 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:
53
54 ....
55 sh -c 'stty -icanon min 1; "$0" "$@"; stty icanon' rename -i from to files
56 ....
57
58 == EXIT STATUS
59
60 *0*::
61 all requested rename operations were successful
62
63 *1*::
64 all rename operations failed
65
66 *2*::
67 some rename operations failed
68
69 *4*::
70 nothing was renamed
71
72 *64*::
73 unanticipated error occurred
74
75 == EXAMPLES
76
77 Given the files _foo1_, ..., _foo9_, _foo10_, ..., _foo278_, the commands
78
79 ....
80 rename foo foo00 foo?
81 rename foo foo0 foo??
82 ....
83
84 will turn them into _foo001_, ..., _foo009_, _foo010_, ..., _foo278_. And
85
86 ....
87 rename .htm .html *.htm
88 ....
89
90 will fix the extension of your html files. Provide an empty string for shortening:
91
92 ....
93 rename '_with_long_name' '' file_with_long_name.*
94 ....
95
96 will remove the substring in the filenames.
97
98 == SEE ALSO
99
100 *mv*(1)
101
102 include::man-common/bugreports.adoc[]
103
104 include::man-common/footer.adoc[]
105
106 ifdef::translation[]
107 include::man-common/translation.adoc[]
108 endif::[]