mved - carefully rename multiple files
usage: mved [options] src dst options:
-h - Print the help message then exit -m - Print the manpage then exit -w - Print the manpage in html format then exit -r - Print the manpage in nroff format then exit -n - Don't rename anything. Just print commands -f - Force dangerous actions (Check with -n first!) -q - Don't print skipping or unlinking messages -v - Print equivalent mv commands (implied by -d) -d - Print debugging messages -b # - Set depth of quote characters to check (default 4)
mved renames multiple files. The src argument is a filename glob
specifying the set of files to rename. The dst argument is a pattern
specifying the new names for the set of files. The src argument can
contain all of the normal shell globbing constructs (?, * and
[...]) as well as = which is a synonym for *. If any normal shell
globbing constructs are used, they must be quoted to prevent the shell from
performing filename expansion. This is not necessary when the only construct
used is =. There are two styles of dst argument. One allows = to
represent the text matching the (positionally) corresponding glob construct
in the src argument. The other allows =#= (where # is an integer)
to represent the text matching the #-th glob construct in the src
argument. The two styles cannot be mixed.
mved creates new links to the existing files. If the -v verbose option
is supplied, the corresponding mv commands are printed. If any of them
fail, they are all unlinked and the operation is aborted. If all were
successful, the original files are unlinked.
Before renaming any files, mved checks for any dubious consequences. If a
source filename is equal to its corresponding destination filename, that
(redundant) renaming operation is skipped. The user is informed unless the
-q quiet option is supplied. If a source filename is equal to some other
destination filename, mved gets nervous and exits unless the -f force
option is supplied. If the same filename is a destination for multiple
source filenames, mved exits unless the -f force option is supplied.
If any file to be created already exists, mved exits unless the -f
force option is supplied. When forced, mved will unlink any existing
destination files. The user will be informed unless the -q quiet option
is supplied.
-h-mman mved
but this works even when the manpage isn't installed properly.
-wmkdir -p /usr/local/share/doc/mved/html && mved -w > /usr/local/share/doc/mved/html/mved.1.html
-rmved -r > /usr/local/share/man/man1/mved.1
-n-f-n first to see what you
are telling mved to do and verifying that it is what you really, really
want to do.
-q-v-d option.
-dsrc and dst arguments before
and after translation from filename globs into regular expressions. Also
print corresponding mv commands when renaming each file.
-b #mved =.c~ bak/=.c.bak
mv a.c~ bak/a.c.bak
mv b.c~ bak/b.c.bak
mv c.c~ bak/c.c.bak
mved '*.[ch]' save-=.=
mv a.c save-a.c
mv a.h save-a.h
mv b.c save-b.c
mv b.h save-b.h
mved save-=.= =.=
mv save-a.c a.c
mv save-a.o a.o
mv save-b.c b.c
mv save-b.o b.o
mved note= note=.txt
mv note1 note1.txt
mv note2 note2.txt
mv note3 note3.txt
mved '[0-9][0-9][0-9][0-9][0-9][0-9]*' 19=5==6=-=3==4=-=1==2==7=
mv 191299-app.log 1999-12-19-app.log
mv 211299-app.log 1999-12-21-app.log
mv 251299-app.log 1999-12-25-app.log
mv 281299-app.log 1999-12-28-app.log
mved returns 0 (zero) upon success, 1 (one) upon failure. Upon failure, no files will have been renamed.
Hard links are used so it is impossible to mved files from one file system to another. Use mv for this. Then rename with mved. This is not really a bug. It is a safety feature.
Doesn't handle patterns containing pipe '|' characters because this
character is used as the regular expression separator.
Presumably, there are as yet unknown bugs and they will presumably cost
files. My advice is to always use -n first, never use -f, and always
keep backups.
Released under the terms of the GPL (http://www.gnu.org/copyleft/gpl.html)
Many years ago on a MIPS far away, there was a program called mved that
renamed multiple files using =. It was very useful but I haven't seen it
since.
link(2), unlink(2), mv(1), rm(1)
20030901 raf <raf@raf.org>
http://raf.org/mved/