On Wed, 11 Aug 2004, Voytek Eymont wrote:
how can I lowercase:
all file names ? all directory names ? recursively ?
Just plug stuff together? find /path/to/start | tac | while read file; do newname=$(echo "$file" | tr A-Z a-z) # could use towlower here i guess mv "$file" "$newname" done
The main trick is the tac so that you rename the parent directories last - otherwise the path would be wrong. Also, its done with while read so it is happy with filenames with spaces, and also Large number of files (more than max args).
If there were also symlinks in the tree, things would be harder. If you could safely assume that all symlinks pointed inside the tree, then you could just lowercase all the targets:
mv "$file" "$newname" if [ -L "$file" ]; then newtarget=$(ls -l "$file" | sed 's/^.* -> //' | tr A-Z a-z) ln -sf "$newtarget" "$newname" fi
Possibly only lowercase relative links: if [ -L "$file" -a "${file:0:1}" != "/" ]; then ...
Cheers,
- Simon
I have user's web data in miXED CAse, and, I think I'd rather lower case it now
I've found this:
# apropos lowercase iswlower (3) - test for lowercase wide character towlower (3) - convert a wide character to lowercase
though this doesn't seem to be a utility I can use ?
-- Voytek -- SLUG - Sydney Linux User's Group Mailing List - http://slug.org.au/ Subscription info and FAQs: http://slug.org.au/faq/mailinglists.html
-- SLUG - Sydney Linux User's Group Mailing List - http://slug.org.au/ Subscription info and FAQs: http://slug.org.au/faq/mailinglists.html