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