Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place! |
| Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
 |
GNU/Linux Basic Guide
This 255-page guide will provide you with the keys to understand the philosophy of free software, teach you how to use and handle it, and give you the tools required to move easily in the world of GNU/Linux. Many users and administrators will be taking their first steps with this GNU/Linux Basic guide and it will show you how to approach and solve the problems you encounter.
Click Here to receive this Complete Guide absolutely free. |
|
 |
11-26-2010, 10:16 PM
|
#1
|
|
Senior Member
Registered: Apr 2007
Location: Buenos Aires.
Distribution: Slackware
Posts: 2,487
Rep:
|
Translating lowercase file names to uppercase.
Kernel 2.6.21.5, Slackware 12.0
Hi:
As a result of having mixed files from different filesystems, I have, in directory foo/, files with filenames in uppercase and files with filenames in lowercase. If I want to convert them to all uppercase how do I do it? Consider this will be later recorded into optical discs. Regards.
Last edited by stf92; 11-26-2010 at 10:17 PM.
|
|
|
|
11-26-2010, 10:24 PM
|
#2
|
|
LQ 5k Club
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian Squeeze (server), Slackware 13.37 (netbook), Slackware64 14.0 (desktop),
Posts: 8,358
|
Something along these lines (untested)?
Code:
#! /bin/bash
# Configure script environment
export PATH=/usr/bin:/bin
set -o nounset
unalias -a
# Rename files
while IFS= read -r -d '' file
do
file_upper=$( echo -n "$file" | /usr/bin/tr '[:upper:]' '[:lower:]' )
echo mv "$file" "$file_upper"
done < <(find foo -type f -print0)
If it is creating the mv commands you want, remove the echo.
|
|
|
|
11-26-2010, 10:25 PM
|
#3
|
|
LQ Veteran
Registered: Nov 2005
Location: London
Distribution: Slackware64-current
Posts: 5,090
|
|
|
|
|
11-26-2010, 10:33 PM
|
#4
|
|
LQ 5k Club
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian Squeeze (server), Slackware 13.37 (netbook), Slackware64 14.0 (desktop),
Posts: 8,358
|
In bash version 4 and later parameter expansion can be used to uppercase a value using var=${var^^}
|
|
|
|
11-26-2010, 10:46 PM
|
#5
|
|
Guru
Registered: Aug 2005
Posts: 9,557
|
it looks like homework BUT with 655 posts - i dought it
lower2CAP.sh
Code:
#!/bin/sh
for i in *; do mv "$i" "$(echo $i | tr '[a-z]' '[A-Z]')"; done
|
|
|
|
11-26-2010, 11:44 PM
|
#6
|
|
Guru
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 6,329
|
I am with catkin for bash 4:
Code:
for x in *;do mv "$x" "${x^^}";done
Or if you have access to rename:
Code:
rename -n 's/(.*)/\U$1/' *
Remove -n to make it happen
|
|
|
|
11-27-2010, 12:43 AM
|
#7
|
|
Senior Member
Registered: Apr 2007
Location: Buenos Aires.
Distribution: Slackware
Posts: 2,487
Original Poster
Rep:
|
Thank you guys, but I've just reconsidered and have seen the problem is unsolvable. Many of the files are of the type
foo.html
foo_files/
If I rename any of the files in foo_files, the HTML page will lack something. Infact, foo.html contains the names of all files in foo_files/. Renaming any of them, means to edit foo.html and change the name there too. Sorry for the inconvenience.
Last edited by stf92; 11-27-2010 at 12:44 AM.
|
|
|
|
11-27-2010, 01:37 AM
|
#8
|
|
Guru
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 6,329
|
Well that would be a fairly simple sed, but the choice is yours.
|
|
|
1 members found this post helpful.
|
| Thread Tools |
Search 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
HTML code is Off
|
|
|
All times are GMT -5. The time now is 12:20 AM.
|
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|