2006-12-06 17:25:41 -06:00
|
|
|
.\" Written by Andries E. Brouwer (aeb@cwi.nl)
|
|
|
|
.\" Placed in the public domain
|
|
|
|
.\"
|
2011-08-18 15:18:34 -05:00
|
|
|
.TH RENAME 1 "June 2011" "util-linux" "User Commands"
|
2006-12-06 17:25:41 -06:00
|
|
|
.SH NAME
|
2011-02-27 09:28:14 -06:00
|
|
|
rename \- rename files
|
2006-12-06 17:25:41 -06:00
|
|
|
.SH SYNOPSIS
|
2009-07-22 04:29:04 -05:00
|
|
|
.B rename
|
2014-12-14 13:45:29 -06:00
|
|
|
[options]
|
|
|
|
.IR "expression replacement file" ...
|
2006-12-06 17:25:41 -06:00
|
|
|
.SH DESCRIPTION
|
|
|
|
.B rename
|
|
|
|
will rename the specified files by replacing the first occurrence of
|
2011-06-11 16:42:45 -05:00
|
|
|
.I expression
|
2006-12-06 17:25:41 -06:00
|
|
|
in their name by
|
2011-06-11 16:42:45 -05:00
|
|
|
.IR replacement .
|
|
|
|
.SH OPTIONS
|
2007-09-04 02:33:36 -05:00
|
|
|
.TP
|
2014-12-14 13:45:31 -06:00
|
|
|
.BR \-s , " \-\-symlink"
|
|
|
|
Do not rename a symlink but its target.
|
2011-06-11 16:42:45 -05:00
|
|
|
.TP
|
2014-12-14 13:45:31 -06:00
|
|
|
.BR \-v , " \-\-verbose"
|
2017-12-23 15:44:34 -06:00
|
|
|
Show which files were renamed, if any.
|
2011-06-11 16:42:45 -05:00
|
|
|
.TP
|
2017-06-06 05:09:34 -05:00
|
|
|
.BR \-n , " \-\-no\-act"
|
2018-03-29 05:58:44 -05:00
|
|
|
Do not make any changes; add
|
2018-05-18 14:21:42 -05:00
|
|
|
.B \-\-verbose
|
2018-03-29 05:58:44 -05:00
|
|
|
to see what would be made.
|
2017-02-13 06:44:38 -06:00
|
|
|
.TP
|
2017-06-06 05:09:34 -05:00
|
|
|
.BR \-o , " \-\-no\-overwrite"
|
2018-03-24 17:53:21 -05:00
|
|
|
Do not overwrite existing files. When
|
2018-05-18 14:21:42 -05:00
|
|
|
.B \-\-symlink
|
2018-03-24 17:53:21 -05:00
|
|
|
is active, do not overwrite symlinks pointing to existing targets.
|
2017-06-06 05:09:34 -05:00
|
|
|
.TP
|
2018-03-24 06:15:55 -05:00
|
|
|
.BR \-i , " \-\-interactive"
|
|
|
|
Ask before overwriting existing files.
|
|
|
|
.TP
|
2014-12-14 13:45:31 -06:00
|
|
|
.BR \-V , " \-\-version"
|
|
|
|
Display version information and exit.
|
2012-11-26 09:50:08 -06:00
|
|
|
.TP
|
2014-12-14 13:45:31 -06:00
|
|
|
.BR \-h , " \-\-help"
|
2011-08-28 04:14:42 -05:00
|
|
|
Display help text and exit.
|
2011-02-27 09:28:14 -06:00
|
|
|
.SH EXAMPLES
|
|
|
|
Given the files
|
2006-12-06 17:25:41 -06:00
|
|
|
.IR foo1 ", ..., " foo9 ", " foo10 ", ..., " foo278 ,
|
|
|
|
the commands
|
|
|
|
.RS
|
2011-06-11 16:42:45 -05:00
|
|
|
.PP
|
2006-12-06 17:25:41 -06:00
|
|
|
.nf
|
2017-09-14 10:30:53 -05:00
|
|
|
rename foo foo00 foo?
|
2006-12-06 17:25:41 -06:00
|
|
|
rename foo foo0 foo??
|
|
|
|
.fi
|
2011-06-11 16:42:45 -05:00
|
|
|
.PP
|
2006-12-06 17:25:41 -06:00
|
|
|
.RE
|
|
|
|
will turn them into
|
|
|
|
.IR foo001 ", ..., " foo009 ", " foo010 ", ..., " foo278 .
|
|
|
|
And
|
|
|
|
.RS
|
2011-06-11 16:42:45 -05:00
|
|
|
.PP
|
2006-12-06 17:25:41 -06:00
|
|
|
.nf
|
|
|
|
rename .htm .html *.htm
|
|
|
|
.fi
|
2011-06-11 16:42:45 -05:00
|
|
|
.PP
|
2006-12-06 17:25:41 -06:00
|
|
|
.RE
|
|
|
|
will fix the extension of your html files.
|
2016-04-05 07:35:24 -05:00
|
|
|
Provide an empty string for shortening:
|
|
|
|
.RS
|
|
|
|
.PP
|
|
|
|
.nf
|
|
|
|
rename '_with_long_name' '' file_with_long_name.*
|
|
|
|
.fi
|
|
|
|
.PP
|
|
|
|
.RE
|
|
|
|
will remove the substring in the filenames.
|
2011-06-11 16:42:45 -05:00
|
|
|
.SH WARNING
|
2018-03-24 06:20:58 -05:00
|
|
|
The renaming has no safeguards by default or without any one of the options
|
|
|
|
.B \-\-no-overwrite\fR,
|
|
|
|
.B \-\-interactive
|
|
|
|
or
|
|
|
|
.B \-\-no\-act\fR.
|
|
|
|
If the user has
|
2017-02-13 06:44:38 -06:00
|
|
|
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.
|
2018-04-02 08:32:44 -05:00
|
|
|
.SH INTERACTIVE MODE
|
|
|
|
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:
|
|
|
|
.RS
|
|
|
|
.PP
|
|
|
|
.nf
|
|
|
|
sh -c 'stty -icanon min 1; "$0" "$@"; stty icanon' rename -i from to files
|
|
|
|
.fi
|
|
|
|
.PP
|
|
|
|
.RE
|
2014-06-28 12:42:49 -05:00
|
|
|
.SH "EXIT STATUS"
|
|
|
|
.RS
|
|
|
|
.PD 0
|
|
|
|
.TP
|
|
|
|
.B 0
|
|
|
|
all requested rename operations were successful
|
|
|
|
.TP
|
|
|
|
.B 1
|
|
|
|
all rename operations failed
|
|
|
|
.TP
|
|
|
|
.B 2
|
|
|
|
some rename operations failed
|
|
|
|
.TP
|
|
|
|
.B 4
|
|
|
|
nothing was renamed
|
|
|
|
.TP
|
|
|
|
.B 64
|
|
|
|
unanticipated error occurred
|
|
|
|
.PD
|
|
|
|
.RE
|
2006-12-06 17:25:41 -06:00
|
|
|
.SH "SEE ALSO"
|
|
|
|
.BR mv (1)
|
2007-07-02 18:17:04 -05:00
|
|
|
.SH AVAILABILITY
|
2010-11-30 04:41:59 -06:00
|
|
|
The rename command is part of the util-linux package and is available from
|
2016-12-17 02:06:57 -06:00
|
|
|
https://www.kernel.org/pub/linux/utils/util-linux/.
|