summaryrefslogtreecommitdiffstats
path: root/misc-utils/rename.1
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--misc-utils/rename.1168
-rw-r--r--misc-utils/rename.1.adoc110
2 files changed, 278 insertions, 0 deletions
diff --git a/misc-utils/rename.1 b/misc-utils/rename.1
new file mode 100644
index 0000000..18bebe8
--- /dev/null
+++ b/misc-utils/rename.1
@@ -0,0 +1,168 @@
+'\" t
+.\" Title: rename
+.\" Author: [see the "AUTHOR(S)" section]
+.\" Generator: Asciidoctor 2.0.15
+.\" Date: 2022-05-11
+.\" Manual: User Commands
+.\" Source: util-linux 2.38.1
+.\" Language: English
+.\"
+.TH "RENAME" "1" "2022-05-11" "util\-linux 2.38.1" "User Commands"
+.ie \n(.g .ds Aq \(aq
+.el .ds Aq '
+.ss \n[.ss] 0
+.nh
+.ad l
+.de URL
+\fI\\$2\fP <\\$1>\\$3
+..
+.als MTO URL
+.if \n[.g] \{\
+. mso www.tmac
+. am URL
+. ad l
+. .
+. am MTO
+. ad l
+. .
+. LINKSTYLE blue R < >
+.\}
+.SH "NAME"
+rename \- rename files
+.SH "SYNOPSIS"
+.sp
+\fBrename\fP [options] \fIexpression replacement file\fP...
+.SH "DESCRIPTION"
+.sp
+\fBrename\fP will rename the specified files by replacing the first occurrence of \fIexpression\fP in their name by \fIreplacement\fP.
+.SH "OPTIONS"
+.sp
+\fB\-s\fP, \fB\-\-symlink\fP
+.RS 4
+Do not rename a symlink but its target.
+.RE
+.sp
+\fB\-v\fP, \fB\-\-verbose\fP
+.RS 4
+Show which files were renamed, if any.
+.RE
+.sp
+\fB\-n\fP, \fB\-\-no\-act\fP
+.RS 4
+Do not make any changes; add \fB\-\-verbose\fP to see what would be made.
+.RE
+.sp
+\fB\-a\fP, \fB\-\-all\fP
+.RS 4
+Replace all occurrences of \fIexpression\fP rather than only the first one.
+.RE
+.sp
+\fB\-l\fP, \fB\-\-last\fP
+.RS 4
+Replace the last occurrence of \fIexpression\fP rather than the first one.
+.RE
+.sp
+\fB\-o\fP, \fB\-\-no\-overwrite\fP
+.RS 4
+Do not overwrite existing files. When \fB\-\-symlink\fP is active, do not overwrite symlinks pointing to existing targets.
+.RE
+.sp
+\fB\-i\fP, \fB\-\-interactive\fP
+.RS 4
+Ask before overwriting existing files.
+.RE
+.sp
+\fB\-h\fP, \fB\-\-help\fP
+.RS 4
+Display help text and exit.
+.RE
+.sp
+\fB\-V\fP, \fB\-\-version\fP
+.RS 4
+Print version and exit.
+.RE
+.SH "WARNING"
+.sp
+The renaming has no safeguards by default or without any one of the options \fB\-\-no\-overwrite\fP, \fB\-\-interactive\fP or \fB\-\-no\-act\fP. 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 \fI/lib\fP directory. Always make a backup before running the command, unless you truly know what you are doing.
+.SH "INTERACTIVE MODE"
+.sp
+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:
+.sp
+.if n .RS 4
+.nf
+.fam C
+sh \-c \(aqstty \-icanon min 1; "$0" "$@"; stty icanon\(aq rename \-i from to files
+.fam
+.fi
+.if n .RE
+.SH "EXIT STATUS"
+.sp
+\fB0\fP
+.RS 4
+all requested rename operations were successful
+.RE
+.sp
+\fB1\fP
+.RS 4
+all rename operations failed
+.RE
+.sp
+\fB2\fP
+.RS 4
+some rename operations failed
+.RE
+.sp
+\fB4\fP
+.RS 4
+nothing was renamed
+.RE
+.sp
+\fB64\fP
+.RS 4
+unanticipated error occurred
+.RE
+.SH "EXAMPLES"
+.sp
+Given the files \fIfoo1\fP, ..., \fIfoo9\fP, \fIfoo10\fP, ..., \fIfoo278\fP, the commands
+.sp
+.if n .RS 4
+.nf
+.fam C
+rename foo foo00 foo?
+rename foo foo0 foo??
+.fam
+.fi
+.if n .RE
+.sp
+will turn them into \fIfoo001\fP, ..., \fIfoo009\fP, \fIfoo010\fP, ..., \fIfoo278\fP. And
+.sp
+.if n .RS 4
+.nf
+.fam C
+rename .htm .html *.htm
+.fam
+.fi
+.if n .RE
+.sp
+will fix the extension of your html files. Provide an empty string for shortening:
+.sp
+.if n .RS 4
+.nf
+.fam C
+rename \(aq_with_long_name\(aq \(aq\(aq file_with_long_name.*
+.fam
+.fi
+.if n .RE
+.sp
+will remove the substring in the filenames.
+.SH "SEE ALSO"
+.sp
+\fBmv\fP(1)
+.SH "REPORTING BUGS"
+.sp
+For bug reports, use the issue tracker at \c
+.URL "https://github.com/util\-linux/util\-linux/issues" "" "."
+.SH "AVAILABILITY"
+.sp
+The \fBrename\fP command is part of the util\-linux package which can be downloaded from \c
+.URL "https://www.kernel.org/pub/linux/utils/util\-linux/" "Linux Kernel Archive" "." \ No newline at end of file
diff --git a/misc-utils/rename.1.adoc b/misc-utils/rename.1.adoc
new file mode 100644
index 0000000..5eb1959
--- /dev/null
+++ b/misc-utils/rename.1.adoc
@@ -0,0 +1,110 @@
+//po4a: entry man manual
+// Written by Andries E. Brouwer (aeb@cwi.nl)
+// Placed in the public domain
+= rename(1)
+:doctype: manpage
+:man manual: User Commands
+:man source: util-linux {release-version}
+:page-layout: base
+:command: rename
+
+== NAME
+
+rename - rename files
+
+== SYNOPSIS
+
+*rename* [options] _expression replacement file_...
+
+== DESCRIPTION
+
+*rename* will rename the specified files by replacing the first occurrence of _expression_ in their name by _replacement_.
+
+== OPTIONS
+
+*-s*, *--symlink*::
+Do not rename a symlink but its target.
+
+*-v*, *--verbose*::
+Show which files were renamed, if any.
+
+*-n*, *--no-act*::
+Do not make any changes; add *--verbose* to see what would be made.
+
+*-a*, *--all*::
+Replace all occurrences of _expression_ rather than only the first one.
+
+*-l*, *--last*::
+Replace the last occurrence of _expression_ rather than the first one.
+
+*-o*, *--no-overwrite*::
+Do not overwrite existing files. When *--symlink* is active, do not overwrite symlinks pointing to existing targets.
+
+*-i*, *--interactive*::
+Ask before overwriting existing files.
+
+include::man-common/help-version.adoc[]
+
+== WARNING
+
+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.
+
+== 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:
+
+....
+sh -c 'stty -icanon min 1; "$0" "$@"; stty icanon' rename -i from to files
+....
+
+== EXIT STATUS
+
+*0*::
+all requested rename operations were successful
+
+*1*::
+all rename operations failed
+
+*2*::
+some rename operations failed
+
+*4*::
+nothing was renamed
+
+*64*::
+unanticipated error occurred
+
+== EXAMPLES
+
+Given the files _foo1_, ..., _foo9_, _foo10_, ..., _foo278_, the commands
+
+....
+rename foo foo00 foo?
+rename foo foo0 foo??
+....
+
+will turn them into _foo001_, ..., _foo009_, _foo010_, ..., _foo278_. And
+
+....
+rename .htm .html *.htm
+....
+
+will fix the extension of your html files. Provide an empty string for shortening:
+
+....
+rename '_with_long_name' '' file_with_long_name.*
+....
+
+will remove the substring in the filenames.
+
+== SEE ALSO
+
+*mv*(1)
+
+include::man-common/bugreports.adoc[]
+
+include::man-common/footer.adoc[]
+
+ifdef::translation[]
+include::man-common/translation.adoc[]
+endif::[]