Transformation capital letter | Unix Linux Forums | UNIX for Dummies Questions & Answers

  Go Back    


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 !!

Transformation capital letter

UNIX for Dummies Questions & Answers


Tags
perl, perl shift, shift, shift perl

Closed Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 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
    #2  
Old 01-24-2002
Kelam_Magnus's Avatar
Kelam_Magnus Kelam_Magnus is offline Forum Advisor  
Registered User
 
Join Date: Aug 2001
Last Activity: 18 April 2013, 3:03 PM EDT
Location: San Antonio, TX,
Posts: 1,070
Thanks: 0
Thanked 4 Times in 4 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.

Code:
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

                        UNIX GURU UNIVERSE & UNIX911.com
                                 UNIX HOT TIP

                        Unix Tip 1661 - July 19, 2001

                    http://www.ugu.com/sui/ugu/show?tip.today
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=


Rename files script

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

#!/usr/bin/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";
        next;
    }
    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 11:36 AM..
Sponsored Links
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 09:36 AM
Regex to find ONLY Capital Letter Strings bulgin Shell Programming and Scripting 7 10-22-2010 12:14 AM
XML to csv transformation siba.s.nayak Shell Programming and Scripting 2 08-14-2009 06:15 AM
converting day to capital letter... govindts Shell Programming and Scripting 8 11-14-2008 07: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 10:35 PM



All times are GMT -4. The time now is 02:17 PM.