Skip site navigation (1)Skip section navigation (2)

FreeBSD Manual Pages


home | help

       renamex - file rename tool

       renamex [options] files ...

       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 regu-
       lar expression for searching and	substituting string  patterns  in  the

       -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.	(supe-
	      ruser only)

       -v, --verbose
	      verbose display.

       -A, --always
	      Always overwrite the existed files

       -N, --never
	      Never  overwrite the existed files, discard the renaming process

	      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 sys-
	      tem  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  sup-
		     port 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.

       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  expres-
       sions, 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  ex-
       pression	[0123456789] matches any single	digit.	A range	of ASCII char-
       acters may be specified by giving the first and last characters,	 sepa-
       rated  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:], [:upper:],	and [:xdigit:].	 For  example,	[[:al-
       num:]]  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  delimiting  the  bracket
       list.)	Most  metacharacters  lose their special meaning inside	lists.
       To include a literal ] place it first in	the list.  Similarly,  to  in-
       clude  a	 literal ^ place it anywhere but first.	 Finally, to include 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 oper-
       ?      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  ex-
       pression	matches	any string formed by concatenating two substrings that
       respectively match the concatenated subexpressions.

       Two regular expressions may be joined by	the infix operator |; the  re-
       sulting	regular	 expression  matches any string	matching either	subex-

       Repetition takes	precedence over	concatenation,	which  in  turn	 takes
       precedence  over	alternation.  A	whole subexpression may	be enclosed in
       parentheses to override these precedence	rules.

       The backreference \n, where n is	a single digit,	matches	the  substring
       previously  matched by the nth parenthesized subexpression of the regu-
       lar expression.

       In basic	regular	expressions the	metacharacters ?, +, {,	|,  (,	and  )
       lose  their  special  meaning; instead use the backslashed versions \?,
       \+, \{, \|, \(, and \).

       mv(1), chown(1),	regex(7), regex(3)

       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  op-
       tion) 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  MER-
       Public License for more details.

       You should have received	a copy of the GNU General Public License along
       with this program.  If not, see <>.

       Please send bug reports to "Andy	Xuming"	<>

       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

       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 be-
	      tween the	capital	letter and 'file' .  The substring, if encoun-
	      tered 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
	      actually 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  di-
	      rectory tree will	be changed to 'guest' .



Want to link to this manual page? Use this URL:

home | help