[Samba] file names convert

Lennart Sorensen lsorense at csclub.uwaterloo.ca
Thu Sep 16 08:51:59 MDT 2010


On Thu, Sep 16, 2010 at 01:38:05PM +0200, Michael Wood wrote:
> On 16 September 2010 09:02, Alessio Tomelleri - ARPAV Dipartimento di
> Belluno <atomelleri at arpa.veneto.it> wrote:
> >  ..maybe could be useful this command ?!  get a closer look   "man tr"
> >
> > tr [:upper:] [:lower:] < myfile
> 
> He wants to change the filename, not the contents :)
> 
> > maybe, inserting it in a script as well...
> 
> Try something like:
> 
> for f in *; do

Breaks on filenames with spaces.

>     lower="`echo $f | tr [:upper:] [:lower:]`"
>     if [ "$f" != "$lower" ]; then
>         mv -i "$f" "$lower"
>     fi
> done
> 
> The "mv -i" is in case you have a file called "README.txt" and another
> one called "Readme.txt" in the same directory.
> 
> Please try it out on some test files before running it in production.

How about "rename 's/(.*)/\L$1\E/' filenames" ?

-- 
Len Sorensen


More information about the samba mailing list