[mdlug] Hideous script for recursively renaming a directory tree to lower case
Jeff Hanson
jhansonxi at gmail.com
Fri Feb 1 23:44:36 EST 2008
I was trying to get an old application to work under Wine. As you all
know, file and directory names are case sensitive in Linux but not in
Windows. Wine hides the differences from the Windows applications.
When an executable update is applied to a Windows app that is designed
to overwrite existing files, Wine treats them as case insensitive so
the correct ones get clobbered. But in the case of the app I was
working with, the update is a zip file that needs to be extracted over
the existing app tree in order to replace some of the files in various
subdirectories. Just to make it fun, the file names in the zip had
different case than the target tree. Not just all upper or lower case
either - lots of random CamelCase also. Since Wine hides the case
from the app renaming everything to lower case doesn't affect it so I
went looking for a shell script, command, or graphical utility to do
that. I found lots of script examples and apps but none of them
worked. The problem is that none of them can handle renaming
directories recursively, especially more than one level deep. The
"find" command can exec another command like "rename" but it parses
the full tree first then runs the app which then fails as soon as it
tries to access a subdirectory of a directory it just renamed. I
threw together this hideous script that exhaustively parses the tree
but does anyone have a better method? My script handles hidden file
names with spaces and other nonsense and I attached a tar.gz of the
tree I was testing against.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: renlctree.sh
Type: application/x-sh
Size: 1070 bytes
Desc: not available
URL: <http://mdlug.org/pipermail/mdlug/attachments/20080201/60d1c40b/attachment-0001.sh>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: test_tree.tar.gz
Type: application/x-gzip
Size: 531 bytes
Desc: not available
URL: <http://mdlug.org/pipermail/mdlug/attachments/20080201/60d1c40b/attachment-0001.gz>
More information about the mdlug
mailing list