Gnuru.org
Productive Linux


Subscribe

 Subscribe via Feedburner in a reader

Enter your email address:

Delivered by FeedBurner


Login
Login:
Password:



Don't have an account?
Sign up to Gnuru.org
Forgot your password?

Converting filenames to lowercase
27 July 2004 @ 13:19 BST
by Paul

The easiest way to convert all the files to lowercase is to use rename. Like this:

rename 'y/A-Z/a-z/' *

Here is a shell script to convert all files in the working directory to lowercase:


#!/bin/bash
for filename in *
do
   n=`echo $filename | tr '[:upper:]' '[:lower:]'`
   mv $filename $n
done

Here is a perl one-line that does the same thing from the command line:

perl -MFile::Copy -e 'move $_, lc($_) foreach glob "*"'

And a perl script that does the same thing:


#!/usr/bin/perl

use warnings;
use strict;
use File::Copy;

move $_, lc($_) foreach glob '*';

Red Hat Certified Technician & Engineer (RHCT and RHCE) Training Guide and Administrator's Reference



The last perl script is dangerous, as it overwrites files when they acquire the same name due to the conversion.


Posted by Guest User on 2006-04-22 15:31:30.
Leave a comment:

Are you human?