The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
.
google unix.com



UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Lowercase to Uppercase ggovotsis AIX 7 10-16-2008 10:07 AM
renaming files in a directory to lowercase vhariprasad Shell Programming and Scripting 1 03-26-2006 12:26 PM
How convert lowercase or uppercase Alex20 Shell Programming and Scripting 5 03-07-2005 07:07 AM
find lowercase filenames jpprial UNIX for Dummies Questions & Answers 4 01-28-2002 04:57 PM
uppercase to lowercase webex Shell Programming and Scripting 4 01-03-2002 02:15 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 01-04-2008
Duke_Lukem Duke_Lukem is offline
Registered User
  
 

Join Date: Jan 2008
Posts: 3
Exclamation Need to change filenames in a particular directory from lowercase to UPPERCASE

Hi,

I need a shell script which changes a bunch of files in a particular directory from lowercase to UPPERCASE.

I am not very familiar with shell scripts so a detailed explanation would be greatly appreciated!!!!

Thanks ini advance!
  #2 (permalink)  
Old 01-04-2008
cassj's Avatar
cassj cassj is offline VIP Member  
Supporter
  
 

Join Date: Jul 2003
Location: Interweb
Posts: 109
Give this a shot. This will change ALL filenames in the current directory from lower to UPPER.
Code:
cd /path/to/your/files

for file in * ; do mv $file `echo $file | sed 's/\(.*\)/\U\1/'` ; done
  #3 (permalink)  
Old 01-04-2008
ghostdog74 ghostdog74 is offline Forum Advisor  
Registered User
  
 

Join Date: Sep 2006
Posts: 2,425
Code:
for file in *
do 
    echo $file|tr '[a-z]' '[A-Z]'
done
I leave it to you to rename the files.
  #4 (permalink)  
Old 01-04-2008
radoulov's Avatar
radoulov radoulov is offline Forum Staff  
addict
  
 

Join Date: Jan 2007
Location: Варна, България / Milano, Italia
Posts: 2,794
If you have zsh:

Code:
autoload -U zmv
zmv '(*)' '${(u)1}'
With ksh (not sure if ksh88 supports it):

Code:
typeset -u t;for f in *;do t="$f";mv "$f" "$t";done
  #5 (permalink)  
Old 01-06-2008
Duke_Lukem Duke_Lukem is offline
Registered User
  
 

Join Date: Jan 2008
Posts: 3
Lowercase to Uppercase file names

Quote:
Originally Posted by cassj View Post
Give this a shot. This will change ALL filenames in the current directory from lower to UPPER.
Code:
cd /path/to/your/files

for file in * ; do mv $file `echo $file | sed 's/\(.*\)/\U\1/'` ; done
Hi cassj,

I tried the above code you generously provided, however the only thing that the code does is add a "U" to the beginning of each filename in the the directory.

Is there some syntax that is slightly incorrect here???
Thanks for your help!
  #6 (permalink)  
Old 01-06-2008
Duke_Lukem Duke_Lukem is offline
Registered User
  
 

Join Date: Jan 2008
Posts: 3
Talking

Quote:
Originally Posted by radoulov View Post
If you have zsh:

Code:
autoload -U zmv
zmv '(*)' '${(u)1}'
With ksh (not sure if ksh88 supports it):

Code:
typeset -u t;for f in *;do t="$f";mv "$f" "$t";done
Hi radoulov,

Your ksh script worked a treat - thanks a bunch!!
  #7 (permalink)  
Old 01-07-2008
cassj's Avatar
cassj cassj is offline VIP Member  
Supporter
  
 

Join Date: Jul 2003
Location: Interweb
Posts: 109
Hmmm.... I just copied and pasted the code I posted and it worked fine for me. I'm using bash. I'm glad radoulov's code worked for you.
Sponsored Links
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -4. The time now is 09:15 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language translation by Google.
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0