[TriLUG] Changing case of files and folders

Tanner Lovelace clubjuggler at gmail.com
Tue Jan 31 20:13:48 EST 2006


How about this one:
--------------------------------------
#!/usr/bin/perl

# Usage: rename perlexpr [files]

($op = shift) || die "Usage: rename perlexpr [filenames]\n";
if (!@ARGV) {
    @ARGV = <STDIN>;
    chop(@ARGV);
}
for (@ARGV) {
    $was = $_;
    eval $op;
    die $@ if $@;
    rename($was,$_) unless $was eq $_;
}
-------------------------------------------------

call it "rename" and then use it like this:

% rename 'tr/a-z/A-Z/' *

You can use any perl expression to change
the filenames.

Cheers,
Tanner

On 1/31/06, William Sutton <william at trilug.org> wrote:
> you need a perl script...preferably something on the order of the
> following:
>
> -----
> #!/usr/bin/perl
> # use strict;
>
> # usage:  script_name directory_to_process
> my $dir = $ARGV[0];
> my @files = `find $dir -type f -print`;
>
> foreach my $file (@files)
> {
>     chomp($file);
>     my $new = uc($file);
>     `mv $dir/$file $dir/$new`;
> }
> -----
>
> Of course I suggest you test that before running it, but it ought to do
> the trick...
>
> --
> William Sutton
>
>
> On Tue, 31 Jan 2006, Roy Vestal wrote:
>
> > I have a directory that I need to uppercase EVERY file and folder (don't
> > ask...long story).
> >
> > What's the easiest way?
> >
> > TIA,
> > Roy
> >
> --
> TriLUG mailing list        : http://www.trilug.org/mailman/listinfo/trilug
> TriLUG Organizational FAQ  : http://trilug.org/faq/
> TriLUG Member Services FAQ : http://members.trilug.org/services_faq/
>


--
Tanner Lovelace
clubjuggler at gmail dot com
http://wtl.wayfarer.org/
(fieldless) In fess two roundels in pale, a billet fesswise and an
increscent, all sable.



More information about the TriLUG mailing list