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

Re: Some basic unix commanding, more please:



virtanen wrote:

> I managed to make a command, which changes some extensions (coming from
> bad copying from dos) like .JPG into .jpg by doing: 
> 
> for file in *.JPG; do  cp $file ${file%.JPG}.jpg; done
> 
> 2) But when I have got files like this 
> 
> NODE23.HTM
> 
> How can I make the names into:
> 
> node23.html
> 
> It isn't so difficult to change the extension, 
> but how to change with one command all the beginnings of the names to
> start with noncapital letters (or in general change the beginnings on the
> filenames)? 

To lowercase the names:

$ for file in *HTM; do mv $file `echo $file | tr A-Z a-z`; done

then you can change the extension from .htm to .html

The trick aboave was embedding a shell command within `backtics`.
It get executed before the command is evaluated.  e.g.

 $ echo TESTING | tr A-Z a-z
 testing

(See also the `mmv' command in the mmv package for another way to
do these things).

Peter



Reply to: