[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: copy with extension rename

From: Bob Proulx
Subject: Re: copy with extension rename
Date: Thu, 18 Sep 2008 20:16:46 -0600
User-agent: Mutt/1.5.13 (2006-08-11)

tns1 wrote:
> I ended up using make to do the job since I am compiling now anyway. 
> This is under cygwin and I don't want to install another 5MB just to 
> rename some files.
> I am really surprised it can't be done easily with cp, since with DOS 
> its just copy *.c *.o.

The paradigm used by Unix-like systems is different than used by
DOS-like system.  While the DOS copy command may make this particular
task easy the Unix shell makes other things easy.

On DOS the commands receive those wildcards "*.c" and "*.o" as
arguments and do the filename matching within the program.  But on
Unix the command line shell expands those into file names and populate
the program argument array with expanded versions of the command prior
to handing it to the program.

For example one of the alternatives to using perl 'rename' script
would be to use the shell to loop over the files and rename them in a

  for f in *.a; do mv -v "$f" "${f%.a}.b" ; done

Or perhaps even this:

  for f in *.a; do echo mv "$f" "${f%.a}.b" ; done | sh -x


reply via email to

[Prev in Thread] Current Thread [Next in Thread]