Unix/Linux Go Back    

UNIX for Dummies Questions & Answers This forum is closed for new posts. Please post beginner questions to learn unix and learn linux in this forum UNIX for Beginners Questions & Answers

Transformation capital letter

UNIX for Dummies Questions & Answers

perl, perl shift, shift, shift perl

Thread Tools Search this Thread Display Modes
Old Unix and Linux 01-24-2002
Dark Angel Dark Angel is offline
Registered User
Join Date: Jan 2002
Last Activity: 28 January 2002, 3:11 AM EST
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
MySQL Transformation capital letter


Hye everybody i would like to know if exist a internet site where i can founs some interesting shell script very usefull

I need to transform hundreds names of files escribed in CAPITAL letter in minuscule letter

do oyu know a mean o do that that thanks to a script or a shell command
Sponsored Links
Old Unix and Linux 01-24-2002
Kelam_Magnus's Unix or Linux Image
Kelam_Magnus Kelam_Magnus is offline Forum Advisor  
Registered User
Join Date: Aug 2001
Last Activity: 24 February 2017, 5:03 PM EST
Location: San Antonio, TX,
Posts: 1,071
Thanks: 0
Thanked 7 Times in 6 Posts
go to www.ugu.com sign up for the tip of the day.

Dear Dark,

Here is a very good script. That should do the trick. You will have to modify it of course.

It is not mine. But here it is.


                        UNIX GURU UNIVERSE & UNIX911.com
                                 UNIX HOT TIP

                        Unix Tip 1661 - July 19, 2001


Rename files script

If you want to rename files
in a directory then you can
use the following perl

# rename: renames files according to the expr given on the command line.
# The expr will usually be a 's' or 'y' command, but can be any valid
# perl command if it makes sense. Takes a list of files to work on or
# defaults to '*' in the current directory.
# e.g.
#       rename 's/\.flip$/.flop/'       # rename *.flip to *.flop
#       rename s/flip/flop/             # rename *flip* to *flop*
#       rename 's/^s\.(.*)/$1.X/'       # switch sccs filenames around
#       rename 's/$/.orig/' */*.[ch]    # add .orig to your source files in
#       rename 'y/A-Z/a-z/'             # lowercase all filenames in .
#       rename 'y/A-Z/a-z/ if -B'       # same, but just binaries!
#       rename chop *~                  # restore all ~ backup files

use Getopt::Std;
my ($subst, $name);

if (!&getopts("nfq") || $#ARGV == -1) {
    die "Usage: rename [-fnq] <perl expression> [file file...]
-f   : Force the new filename even if it exists already
-n   : Just print what would happen, but don't do the command
-q   : Don't print the files as they are renamed
e.g. : rename  's/\.c/.c.old/' *
       rename -q 'y/A-Z/a-z/' *\n";

$subst = shift;                 # Get perl command to work on
@ARGV = <*> if $#ARGV < 0;      # Default to complete directory

foreach $name (@ARGV) {
    $_ = $name;
    eval "$subst;";
    die $@ if $@;
    next if -e $_ && !$opt_f;   # Skip if the file exists if asked to.
    mext if $_ eq $name;
    if ($opt_n) {
        print "mv $name $_\n";
    print "mv $name $_\n" if !$opt_q;
    rename($name,$_) or warn "Can't rename $name to $_, $!\n";

Put the script called rename in /usr/local/bin. Make sure
/usr/local/bin is in your $PATH for convenience.

This tip generously supported by: dave.ruddle@siemens.co.uk

inserted code tags --oombera

Last edited by oombera; 02-16-2004 at 10:36 AM..
Sponsored Links

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Linux More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
[Solved] check if chars is a capital letter and translate it tafazzi87 Shell Programming and Scripting 7 11-11-2011 08:36 AM
XML to csv transformation siba.s.nayak Shell Programming and Scripting 2 08-14-2009 05:15 AM
converting day to capital letter... govindts Shell Programming and Scripting 8 11-14-2008 06:46 PM
how to find capital letter names in a file without finding words at start of sentence kev269 Shell Programming and Scripting 1 04-10-2006 09:35 PM

All times are GMT -4. The time now is 09:51 AM.