LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices

Reply
 
Search this Thread
Old 06-03-2005, 06:21 AM   #1
slpwkr
LQ Newbie
 
Registered: Mar 2005
Location: philippines
Posts: 18

Rep: Reputation: 0
Renaming All Caps Filename Into Lower Case


HIgh guuys I have this folder that consist all caps filename like:

INDEX.HTML
MEMBERS.HTML
CONFIRM.HTML
SUB.HTML
ALL.HTML

ETC..


Its too many to manually rename each file. Is there a linux command to convert all caps filename into a lowercase?

Thank You.
 
Old 06-03-2005, 06:39 AM   #2
trevelluk
Member
 
Registered: Nov 2003
Location: Bristol, UK
Distribution: Debian Lenny, Gentoo (at work)
Posts: 388

Rep: Reputation: 32
I don't know of any builtins to do this, but you could probably do this with a little shell script:

Code:
#!/bin/bash

for oldname in `ls`; do
    # tr translates characters from the first set specified to the corresponding character in the second set
    #in this case uppercase to lowercase
    newname=`echo $oldname | tr [:upper:] [:lower:]`
    mv oldname newname
done
I haven't tested this, but I think it should work (I advise you test with non-critical data first though).
 
Old 06-03-2005, 07:05 AM   #3
slpwkr
LQ Newbie
 
Registered: Mar 2005
Location: philippines
Posts: 18

Original Poster
Rep: Reputation: 0
How should I run the script its should be ./scriptname.sh right? where is the old filen name and the new filename? Anyway, I think the script is good only for few files to be renamed coz it is specific to which file? What if there is a hundred to be renamed? Thanks you
 
Old 06-03-2005, 07:23 AM   #4
trevelluk
Member
 
Registered: Nov 2003
Location: Bristol, UK
Distribution: Debian Lenny, Gentoo (at work)
Posts: 388

Rep: Reputation: 32
To run the script it's just ./filename
You only need the .sh if you actually saved the script file with the extension .sh

Ah, I've just noticed a mistake. The mv line should in fact read mv $oldname $newname

(edit)Just one more thing, this won't work on case-insensitive filesystems (e.g. vfat).

Last edited by trevelluk; 06-03-2005 at 08:48 AM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Upper and lower case problem when mount hardisk UltraSoul Linux - Newbie 1 10-28-2005 09:50 AM
Why are all my upper case files being shown as lower case?? [Kernel 2.6.9-1.667 FC3] t3gah Fedora 4 03-11-2005 05:09 PM
Lower case to upper case letter sudhasmyle Programming 1 12-03-2004 05:15 AM
chaging directory names to lower case andy753421 Linux - General 2 05-11-2004 03:12 PM
Apache and upper or lower case. dsiguy Linux - General 3 02-04-2003 12:02 PM


All times are GMT -5. The time now is 03:12 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration