Re: copy with extension rename
tns1 <[email protected]> Thu, 18 Sep 2008 21:45:21 -0700
| Newsgroups | gmane.comp.gnu.utils |
|---|---|
| Organization | Cox |
| Message-ID | <[email protected]> |
Bob Proulx wrote:
> 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
> loop.
>
> 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
>
> Bob
>
>
Thanks, exactly what I wanted. I'll have to add those to my linux cheat
sheet.