Hi folks-- Not specifically SuSE-related, but I have a collection of Linux stuff whose filenames are all in uppercase. Is there some sort of utility that will go through each subdirectory recursively and convert all uppercase filenames to lowercase? TIA....
--- jerry bookter <jerryb1961@yahoo.com> wrote:
Hi folks--
Not specifically SuSE-related, but I have a collection of Linux stuff whose filenames are all in uppercase. Is there some sort of utility that will go through each subdirectory recursively and convert all uppercase filenames to lowercase? TIA....
Found the answer to my own question. The following shell script will do it, though it doesn't work on empty directories: for f in `find . -type d`; do g=`expr "xxx$f" : 'xxx\(.*\)' | tr '[A-Z]' '[a-z]'` mv "$f" "$g" done for f in `find . ! -type d`; do g=`expr "xxx$f" : 'xxx\(.*\)' | tr '[A-Z]' '[a-z]'` mv "$f" "$g" done Still no joy on getting the app in question to run though. Oh well...
On Wednesday 04 January 2006 02:56, jerry bookter wrote:
Found the answer to my own question. The following shell script will do it, though it doesn't work on empty directories:
for f in `find . -type d`; do g=`expr "xxx$f" : 'xxx\(.*\)' | tr '[A-Z]' '[a-z]'` mv "$f" "$g" done for f in `find . ! -type d`; do g=`expr "xxx$f" : 'xxx\(.*\)' | tr '[A-Z]' '[a-z]'` mv "$f" "$g" done
That seems overly complicated. How about find -type f | while read i ; do mv "$i" "`echo \"$i\" | tr A-Z a-z`" ; done Should work on empty directories too. -Andi
find -type f | while read i ; do mv "$i" "`echo \"$i\" | tr A-Z a-z`" ; done
Better, but still won't work on non-American characters, and non-empty directories with uppercase characters, as the directory gets lowercased before its contents are dealt with. find -depth doesn't help. One doesn't get around renaming all the last path components before renaming a second-last one. The general solution isn't so trivial, look at function lowerall() in the Ren script of my scriptutils package. find -depth -print0 | xargs -0 --no-run-if-empty Ren -Lower (or fxargs -depth -- Ren -Lower for the lazy types like me) will work. Volker -- Volker Kuhlmann is possibly list0570 with the domain in header http://volker.dnsalias.net/ Please do not CC list postings to me.
On Wednesday 04 January 2006 22:12, Volker Kuhlmann wrote:
find -type f | while read i ; do mv "$i" "`echo \"$i\" | tr A-Z a-z`" ; done
Better, but still won't work on non-American characters, and non-empty directories with uppercase characters, as the directory gets lowercased before its contents are dealt with.
It won't touch directories. type f only finds regular files. When I read it I assumed the idea was to run it twice, first with type f then with type d
On Wednesday 04 January 2006 22:19, Anders Johansson wrote:
On Wednesday 04 January 2006 22:12, Volker Kuhlmann wrote:
find -type f | while read i ; do mv "$i" "`echo \"$i\" | tr A-Z a-z`" ; done
Better, but still won't work on non-American characters, and non-empty directories with uppercase characters, as the directory gets lowercased before its contents are dealt with.
It won't touch directories. type f only finds regular files. When I read it I assumed the idea was to run it twice, first with type f then with type d
It won't be able to deal with upper case directories. That's a bug (or let's call it a "now documented feature") in my variant yes. -Andi
participants (4)
-
Anders Johansson
-
Andi Kleen
-
jerry bookter
-
Volker Kuhlmann