LINUX.IE, website of the Irish Linux Users' Group
Tux rules!

   
Home
New Users
Articles
Download
Projects
Community
Vendors

  Print Version
Email to...
 
Archives:


planetILUG

Recent News

News Archive


Join the
ILUG
on FaceBook


Join the
ILUG
on LinkedIn


Join the
ILUG SETI
Group



















 
 :: Mailing Lists

[ILUG] Script junkies

[ILUG] Script junkies

Padraig Brady Padraig at AnteFacto.com
Tue Apr 10 17:40:24 IST 2001


You could do this a few ways. The bottom is most efficient by far.
note run the "find case lint" component of 
http://freashmeat.net/projects/fslint if you're worried about loosing
files where there is a case clash

-------------------------------------------

find root_of_cd -depth -exec mv {} `echo {} | tr A-Z a-z` \;
 
-------------------------------------------
 
#!/bin/sh
#pass either filenames or nothing
#note doesn't touch directories

if [ $# = 0 ]
then
	FILES=$(find -type f -maxdepth 1)
else
	FILES="$@"
fi

for FILE in $FILES
do
  DEST=$(echo $FILE | tr A-Z a-z)
  if [ "$DEST" != "$FILE" ] #if file already lowercase
  then
	  mv -i "$FILE" "$DEST" #-i prompts for confirmation (-f is
opposite)
  fi
done

-------------------------------------------

find -depth \( -type f -o -type d \) |
grep -E "/[^/]*[A-Z]+[^/]*$" |
sed -e '
{
    h
    y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/
    G
    s/\(.*\)\n\(.*\)/"\2" "\1"/
}' |
xargs -r -n2 mv
-------------------------------------------


Fergal Moran wrote:
> 
> Can someone tell me how I would rename all files in a folder and subfolders
> to lowercase filenames please.
> 
> Cheers,
> 
> Fergal
> --
> WASP Technologies




More information about the ILUG mailing list
Read this without the formatting.
                                                                                                    

 

Hosted by HEAnet


Maintained by the ILUG website team. The aim of Linux.ie is to support and help commercial and private users of Linux in Ireland. You can display ILUG news in your own webpages, read backend information to find out how. Networking services kindly provided by HEAnet, server kindly donated by Dell. Linux is a trademark of Linus Torvalds, used with permission. No penguins were harmed in the production or maintenance of this highly praised website. Looking for the Indian Linux Users' Group? Try here. If you've read all this and aren't a lawyer: you should be!
RSS Version
Powered by Dell