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. > >> 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" ? > > Ah, I wasn't aware of that. Thanks. It's a handy tool that comes with perl I believe. So the regex is perl regex. -- Len Sorensen -- To unsubscribe from this list go to the following URL and read the instructions: https://lists.samba.org/mailman/options/samba
