]> git.ipfire.org Git - thirdparty/util-linux.git/blob - misc-utils/rename.1.adoc
po: merge changes
[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 *-a*, *--all*::
35 Replace all occurrences of _expression_ rather than only the first one.
36
37 *-l*, *--last*::
38 Replace the last occurrence of _expression_ rather than the first one.
39
40 *-o*, *--no-overwrite*::
41 Do not overwrite existing files. When *--symlink* is active, do not overwrite symlinks pointing to existing targets.
42
43 *-i*, *--interactive*::
44 Ask before overwriting existing files.
45
46 include::man-common/help-version.adoc[]
47
48 == WARNING
49
50 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.
51
52 == INTERACTIVE MODE
53
54 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:
55
56 ....
57 sh -c 'stty -icanon min 1; "$0" "$@"; stty icanon' rename -i from to files
58 ....
59
60 == EXIT STATUS
61
62 *0*::
63 all requested rename operations were successful
64
65 *1*::
66 all rename operations failed
67
68 *2*::
69 some rename operations failed
70
71 *4*::
72 nothing was renamed
73
74 *64*::
75 unanticipated error occurred
76
77 == EXAMPLES
78
79 Given the files _foo1_, ..., _foo9_, _foo10_, ..., _foo278_, the commands
80
81 ....
82 rename foo foo00 foo?
83 rename foo foo0 foo??
84 ....
85
86 will turn them into _foo001_, ..., _foo009_, _foo010_, ..., _foo278_. And
87
88 ....
89 rename .htm .html *.htm
90 ....
91
92 will fix the extension of your html files. Provide an empty string for shortening:
93
94 ....
95 rename '_with_long_name' '' file_with_long_name.*
96 ....
97
98 will remove the substring in the filenames.
99
100 == SEE ALSO
101
102 *mv*(1)
103
104 include::man-common/bugreports.adoc[]
105
106 include::man-common/footer.adoc[]
107
108 ifdef::translation[]
109 include::man-common/translation.adoc[]
110 endif::[]