Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Convert files/directories to lowercase
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks
View previous topic :: View next topic  
Author Message
pjp
Administrator
Administrator


Joined: 16 Apr 2002
Posts: 20506

PostPosted: Fri Jun 28, 2002 4:36 am    Post subject: Convert files/directories to lowercase Reply with quote

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
View user's profile Send private message
S_aIN_t
Guru
Guru


Joined: 11 May 2002
Posts: 488
Location: Ottawa

PostPosted: Fri Jun 28, 2002 4:53 am    Post subject: Reply with quote

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
View user's profile Send private message
pjp
Administrator
Administrator


Joined: 16 Apr 2002
Posts: 20506

PostPosted: Fri Jun 28, 2002 6:57 am    Post subject: Reply with quote

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
View user's profile Send private message
hilker
n00b
n00b


Joined: 26 Jun 2002
Posts: 3

PostPosted: Fri Jun 28, 2002 10:19 pm    Post subject: rename Reply with quote

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
View user's profile Send private message
pjp
Administrator
Administrator


Joined: 16 Apr 2002
Posts: 20506

PostPosted: Fri Jun 28, 2002 10:33 pm    Post subject: Reply with quote

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
View user's profile Send private message
TGL
Bodhisattva
Bodhisattva


Joined: 02 Jun 2002
Posts: 1978
Location: Rennes, France

PostPosted: Sat Jun 29, 2002 12:14 pm    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum