renaming files
Marc Teitelbaum
marc at ucbvax.BERKELEY.EDU
Fri Apr 29 21:07:42 AEST 1988
I was waiting for someone else to post this, but...
Although i hardly ever use it (i tend to use shell loops like those
previously suggested), there was a command posted to net.sources
a while back which does just the sort of transformation on shell-like
file globed lists you need, and in a generalized way. I include
the (semi-literate) man page at the end. If anyone wants code i'll
post to comp.sources.unix.
Marc
-----------
Marc Teitelbaum
457 Evans Hall
Computer Systems Research Group - CSRG
University of California
Berkeley, CA 94720
=================================
NAME
mkcmd - expand complicated global commands
SYNOPSIS
mkcmd commandstring > shellfile
mkcmd commandstring | sh
DESCRIPTION
There is now a command to do those impossible wild card
requests like rename everything which ends with ".ftn" to end
with ".f4p" . This is done by:
% mkcmd "mv *.ftn #.f4p" > file
% sh file
mkcmd generates a command file on its std output which can be
examined on your terminal, redirected into a command file, or
piped directly into the shell.
'#' is the new special character introduced with mkcmd. It
represents the string matched by '*,[],or ?' . If there are more
than one wild card specifications in the file name, they may be
referenced by '#1', '#2', ..., '#9'. e.g.:
% mkcmd "mv *.[cs] #1.#2.old" >file
will generate a command file which will add the extension ".old"
to all files which end either ".c" or ".s" .
'#1' represents the string matched by the '*' and '#2'
represents the character matched by the '[cs]' .
'?' is also allowed and matches any single character.
'#0' represents the logname of the owner of the file matched.
e.g.:
% mkcmd "/tmp/* is owned by #0"
will give a listing of all files in /tmp and their owners.
More information about the Comp.unix.questions
mailing list