[Samba] file names convert
Michael Wood
esiotrot at gmail.com
Sat Sep 18 16:31:11 MDT 2010
On 19 September 2010 00:28, Michael Wood <esiotrot at gmail.com> wrote:
> On 17 September 2010 18:48, Lennart Sorensen
> <lsorense at csclub.uwaterloo.ca> wrote:
>> On Fri, Sep 17, 2010 at 10:24:29AM +0200, Michael Wood wrote:
>>> No, it does not:
>>>
>>> $ touch "File With Spaces.txt"
>>> $ touch "Other File Also With Spaces.txt"
>>> $ touch lowercase.txt
>>> $ touch duplicate.txt
>>> $ touch DUPLICATE.txt
>>> $ for f in *; do lower="`echo $f | tr [:upper:] [:lower:]`"; if [ "$f"
>>> != "$lower" ]; then mv -i "$f" "$lower"; fi; done
>>> mv: overwrite `duplicate.txt'? n
>>> $ ls -l
>>> total 0
>>> -rw-r--r-- 1 michael michael 0 2010-09-17 10:19 duplicate.txt
>>> -rw-r--r-- 1 michael michael 0 2010-09-17 10:19 DUPLICATE.txt
>>> -rw-r--r-- 1 michael michael 0 2010-09-17 10:18 file with spaces.txt
>>> -rw-r--r-- 1 michael michael 0 2010-09-17 10:19 lowercase.txt
>>> -rw-r--r-- 1 michael michael 0 2010-09-17 10:19 other file also with spaces.txt
>>
>> Oh I see, I missed that it did actually have quotes for the mv. Yeah the
>> echo doesn't matter.
>>
>> I do wonder if it would work if you had two spaces in a row. I suspect
>> it would compact multispace to one space. Probably would convert tabs
>> to spaces too. Probably not a common case, but hey gotta make sure it
>> is perfect.
>
> hmmm... You got me there.
OK, fixed:
for f in *; do
lower=`echo "$f" | tr [:upper:] [:lower:]`
if [ "$f" != "$lower" ]; then
mv -i "$f" "$lower"
fi
done
Of course it's still better to use "rename".
--
Michael Wood <esiotrot at gmail.com>
More information about the samba
mailing list