View previous topic :: View next topic |
Author |
Message |
pjp Administrator
Joined: 16 Apr 2002 Posts: 20496
|
Posted: Fri Jun 28, 2002 4:36 am Post subject: Convert files/directories to lowercase |
|
|
Here's a simple but handy way to convert files (and directories) to lowercase.
If you're moving data from a Windows environment, this can be especially handy.
Note: Be careful when using. It has no checks or options... it simply changes any
file or directory (where you have permission) to all lowercase.
I put scripts in a directory in my home that is in my PATH. Be sure to change
the file to executable.
Code: | #!/bin/bash
# Script to convert filenames/directories to lowercase
#
for f in *; do
mv $f `echo $f | tr '[A-Z]' '[a-z]'`
done |
I saw it on another forum, thought it handy enough to post here. _________________ Quis separabit? Quo animo? |
|
Back to top |
|
|
S_aIN_t Guru
Joined: 11 May 2002 Posts: 488 Location: Ottawa
|
Posted: Fri Jun 28, 2002 4:53 am Post subject: |
|
|
looks interesting.. maybe when i am bored to death at work i will write a version in Python and put in some checks and so on..
make sure that you actually dont rename files that are supposed to have a mix of lower and upper case characters.. |
|
Back to top |
|
|
pjp Administrator
Joined: 16 Apr 2002 Posts: 20496
|
Posted: Fri Jun 28, 2002 6:57 am Post subject: |
|
|
Good point.... but mainly I think it would be useful for converting files from a windows
drive where case wouldn't matter. This is not really a tool to be used on system files. _________________ Quis separabit? Quo animo? |
|
Back to top |
|
|
hilker n00b
Joined: 26 Jun 2002 Posts: 3
|
Posted: Fri Jun 28, 2002 10:19 pm Post subject: rename |
|
|
Why not just use rename, which is part of perl in Debian (don't know about Gentoo, waiting until I get broadband to try it):
Code: | rename 'y/[A-Z]/[a-z]/' filename |
It's also useful for replacing underscores in filenames with spaces: Code: | rename 's/_/ /g' filename | Crucial with abcde, I think. |
|
Back to top |
|
|
pjp Administrator
Joined: 16 Apr 2002 Posts: 20496
|
Posted: Fri Jun 28, 2002 10:33 pm Post subject: |
|
|
If rename is part of perl, then this would be for those that don't have/want perl
Didn't know rename existed, thanks for the tip.
EDIT:
hilker wrote: | Crucial with abcde, I think. |
What does that mean? _________________ Quis separabit? Quo animo? |
|
Back to top |
|
|
TGL Bodhisattva
Joined: 02 Jun 2002 Posts: 1978 Location: Rennes, France
|
Posted: Sat Jun 29, 2002 12:14 pm Post subject: |
|
|
Quote: | What does that mean? |
"abcde" is an all-in-one command-line cd encoding tool. I've just discovered it thanks to hilker's post. It seems very cool, but this is quite off-topic...
The point is it generates filenames (from cddb queries) which are full of underscores, and I think that's why hilker use his "rename" command on it. |
|
Back to top |
|
|
|