How can I recursively change the case of files and folders under bash
I have some files and folders that are all in uppercase that I want to rename to their lowercase equivalent. What would be the best way to go about doing this in bash on a Linux system?
As an example I might have:
.
|-- FOLDER0
| |-- SUBFOLDERA
| `-- SUBFOLDERB
`-- FOLDER1
`-- AFILE.TXT
And I want to convert it to:
.
|-- folder0
| |-- subfoldera
| `-- subfolderb
`-- folder1
`-- afile.txt
I can probably write a depth first recursive script to do this (depth first to ensure that files and subfolders are renamed before their parent folder), but I was wondering if there is a better way. rename might be useful, but it doesn’t seem to support recursion.
find . -depth -print0 | xargs -0 rename -n '$_ = lc $_'
Take out the -n flag once you’re sure that it’s doing what you want.
Check more discussion of this question.
Related posts:
Leave a comment
Recent Posts
Tags
active-directory
amazon-ec2
apache
apache2
backup
bash
centos
cisco
command-line
debian
dns
email
exchange
firewall
iis
iis7
iptables
linux
macosx
monitoring
mysql
networking
nginx
performance
permissions
php
postfix
raid
security
sql-server
sql-server-2005
sql-server-2008
ssh
ssl
ubuntu
unix
virtualization
vpn
webserver
windows
windows-7
windows-server-2003
windows-server-2008
windows-server-2008-r2
windows-xp





