FreeBSD Manual Pages
NAME(SECTION) NAME(SECTION) Name renamex - file rename tool SYNOPSIS renamex [options] files ... DESCRIPTION Renamex is a small and quick tool written in C to rename files. It can change, lowercase and uppercase the names of a batch of files, or change the files' ownership. Renamex is powered by the extended regular expres- sion for searching and substituting string patterns in the names. OPTIONS -l, --lowercase Lowercase specified filenames. -u, --uppercase Uppercase specified filenames. -R, --recursive Perform on the specified files and all subdirectories. -t, --test Test only mode. It won't change anything, just test the result of searching and substituting. -f, --file Load file names from the specified files. -o, --owner OWNER Change the ownership of the specified files to OWNER. (superuser only) -v, --verbose verbose display. -A, --always Always overwrite the existed files -N, --never Never overwrite the existed files, discard the renaming process in- stead -s/PATTERN/STRING[/SW] Substitute PATTERN with STRING in the filenames. renamex will searching the PATTERN in the names. If the PATTERN matches, it would be replaced by the specified STRING and then call the system call to change the file's name. SW can be combined by the following switches: g replace all occurrences in the filename. i ignore case when searching. b backward searching and substituting. This does not support regular expression. s change file's suffix. In this case, the PATTERN should be some kind of filename suffix. r declare that PATTERN is a regular expression. e declare that PATTERN is an extended regular expression. 1-9 replace 1 to 9 occurrences in the filename. REGULAR EXPRESSION This section about extended regular expression is digisted from the manpage of fgrep(1). See it for details. A regular expression is a pattern that describes a set of strings. Regular expressions are constructed analogously to arithmetic expressions, by using various operators to combine smaller expressions. The fundamental building blocks are the regular expressions that match a single character. Most characters, including all letters and digits, are regular expressions that match themselves. Any metacharacter with special meaning may be quoted by preceding it with a backslash. A list of characters enclosed by [ and ] matches any single character in that list; if the first character of the list is the caret ^ then it matches any character not in the list. For example, the regular expression [0123456789] matches any single digit. A range of ASCII characters may be specified by giving the first and last characters, separated by a hyphen. Finally, certain named classes of characters are predefined. Their names are self explanatory, and they are [:alnum:], [:alpha:], [:cntrl:], [:digit:], [:graph:], [:lower:], [:print:], [:punct:], [:space:], [:up- per:], and [:xdigit:]. For example, [[:alnum:]] means [0-9A-Za-z], except the latter form is dependent upon the ASCII character encoding, whereas the former is portable. (Note that the brackets in these class names are part of the symbolic names, and must be included in addition to the brackets de- limiting the bracket list.) Most metacharacters lose their special meaning inside lists. To include a literal ] place it first in the list. Simi- larly, to include a literal ^ place it anywhere but first. Finally, to in- clude a literal - place it last. The period . matches any single character. The symbol \w is a synonym for [[:alnum:]] and \W is a synonym for [^[:alnum]]. The caret ^ and the dollar sign $ are metacharacters that respectively match the empty string at the beginning and end of a line. The symbols \< and \> respectively match the empty string at the beginning and end of a word. The symbol \b matches the empty string at the edge of a word, and \B matches the empty string provided it's not at the edge of a word. A regular expression may be followed by one of several repetition opera- tors: ? The preceding item is optional and matched at most once. * The preceding item will be matched zero or more times. + The preceding item will be matched one or more times. {n} The preceding item is matched exactly n times. {n,} The preceding item is matched n or more times. {,m} The preceding item is optional and is matched at most m times. {n,m} The preceding item is matched at least n times, but not more than m times. Two regular expressions may be concatenated; the resulting regular expres- sion matches any string formed by concatenating two substrings that respec- tively match the concatenated subexpressions. Two regular expressions may be joined by the infix operator |; the result- ing regular expression matches any string matching either subexpression. Repetition takes precedence over concatenation, which in turn takes prece- dence over alternation. A whole subexpression may be enclosed in parenthe- ses to override these precedence rules. The backreference \n, where n is a single digit, matches the substring pre- viously matched by the nth parenthesized subexpression of the regular ex- pression. In basic regular expressions the metacharacters ?, +, {, |, (, and ) lose their special meaning; instead use the backslashed versions \?, \+, \{, \|, \(, and \). SEE ALSO mv(1), chown(1), regex(7), regex(3) COPYING This is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FIT- NESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. BUGS Please send bug reports to "Andy Xuming" <xuming@users.sourceforge.net> EXAMPLES renamex -l -R * To lowercase all files' names recursively. renamex -u -s/abc/xyz/gi *.c Substitute all abc substrings appeared in C sources files with xyz , ignoring the case, then uppercase the whole file name. renamex -v -s/.c/.cpp/s * Find all files with the '.c' suffix in the current directory and change them to '.cpp' suffix. Print the verbose information. find . -name *.c > filename.lst renamex -s/.c/.cpp/s -f filename.lst Find all files with the '.c' suffix under the current directory and change them to '.cpp' suffix by the list file. renamex -s/abc/12345/bi * Read names from the 'filename.lst' , find the last occurrence of 'abc' and replace it with '12345' , ignoring the case. renamex -s/^[A-Z].*file/nofile/r * The target substring starts with a capital letter, and ends with string 'file' . There are 0 or any numbers of characters between the capital letter and 'file' . The substring, if encountered in filenames, will be replaced with 'nofile'. renamex -s/^[A-Z].+file/nofile/eg * Similar to above, except it uses extended regular expression, such as the '+' metacharacter, and replaces all matching strings with 'nofile'. renamex -t -s/^[A-Z].+file/nofile/eg * Testmode only. Simulate the rename process but no files would be ac- tually changed. renamex -o guest -R /home/custom change the ownership of '/home/custom' to 'guest' . The 'guest' should be an effective user in the current system. If '/home/custom' is a directory, all files' ownership in this directory tree will be changed to 'guest' . NAME(SECTION)
Name | SYNOPSIS | DESCRIPTION | OPTIONS | REGULAR EXPRESSION | SEE ALSO | COPYING | BUGS | EXAMPLES
Want to link to this manual page? Use this URL:
<https://man.freebsd.org/cgi/man.cgi?query=renamex&manpath=FreeBSD+15.1-RELEASE+and+Ports>
