]> git.ipfire.org Git - thirdparty/util-linux.git/blob - misc-utils/rename.1
rfkill: merge rfkill.8 project to util-linux
[thirdparty/util-linux.git] / misc-utils / rename.1
1 .\" Written by Andries E. Brouwer (aeb@cwi.nl)
2 .\" Placed in the public domain
3 .\"
4 .TH RENAME 1 "June 2011" "util-linux" "User Commands"
5 .SH NAME
6 rename \- rename files
7 .SH SYNOPSIS
8 .B rename
9 [options]
10 .IR "expression replacement file" ...
11 .SH DESCRIPTION
12 .B rename
13 will rename the specified files by replacing the first occurrence of
14 .I expression
15 in their name by
16 .IR replacement .
17 .SH OPTIONS
18 .TP
19 .BR \-s , " \-\-symlink"
20 Do not rename a symlink but its target.
21 .TP
22 .BR \-v , " \-\-verbose"
23 Show which files where renamed, if any.
24 .TP
25 .BR \-n , " \-\-no\-act"
26 Do not make any changes.
27 .TP
28 .BR \-o , " \-\-no\-overwrite"
29 Do not overwrite existing files.
30 .TP
31 .BR \-V , " \-\-version"
32 Display version information and exit.
33 .TP
34 .BR \-h , " \-\-help"
35 Display help text and exit.
36 .SH EXAMPLES
37 Given the files
38 .IR foo1 ", ..., " foo9 ", " foo10 ", ..., " foo278 ,
39 the commands
40 .RS
41 .PP
42 .nf
43 rename foo foo0 foo?
44 rename foo foo0 foo??
45 .fi
46 .PP
47 .RE
48 will turn them into
49 .IR foo001 ", ..., " foo009 ", " foo010 ", ..., " foo278 .
50 And
51 .RS
52 .PP
53 .nf
54 rename .htm .html *.htm
55 .fi
56 .PP
57 .RE
58 will fix the extension of your html files.
59 Provide an empty string for shortening:
60 .RS
61 .PP
62 .nf
63 rename '_with_long_name' '' file_with_long_name.*
64 .fi
65 .PP
66 .RE
67 will remove the substring in the filenames.
68 .SH WARNING
69 The renaming has no safeguards except the
70 .B \-\-no\-act
71 option. If the user has
72 permission to rewrite file names, the command will perform the action without
73 any questions. For example, the result can be quite drastic when the command
74 is run as root in the /lib directory. Always make a backup before running the
75 command, unless you truly know what you are doing.
76 .SH "EXIT STATUS"
77 .RS
78 .PD 0
79 .TP
80 .B 0
81 all requested rename operations were successful
82 .TP
83 .B 1
84 all rename operations failed
85 .TP
86 .B 2
87 some rename operations failed
88 .TP
89 .B 4
90 nothing was renamed
91 .TP
92 .B 64
93 unanticipated error occurred
94 .PD
95 .RE
96 .SH "SEE ALSO"
97 .BR mv (1)
98 .SH AVAILABILITY
99 The rename command is part of the util-linux package and is available from
100 https://www.kernel.org/pub/linux/utils/util-linux/.