From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from lists.gentoo.org ([140.105.134.102] helo=robin.gentoo.org) by nuthatch.gentoo.org with esmtp (Exim 4.62) (envelope-from ) id 1I5Tvs-000665-7R for garchives@archives.gentoo.org; Mon, 02 Jul 2007 21:59:44 +0000 Received: from robin.gentoo.org (localhost [127.0.0.1]) by robin.gentoo.org (8.14.0/8.14.0) with SMTP id l62Lv2Nq027327; Mon, 2 Jul 2007 21:57:02 GMT Received: from mail.askja.de (mail.askja.de [83.137.103.136]) by robin.gentoo.org (8.14.0/8.14.0) with ESMTP id l62Lm5b4012911 for ; Mon, 2 Jul 2007 21:48:05 GMT Received: from xdsl-213-196-211-252.netcologne.de ([213.196.211.252] helo=zone.wonkology.org) by mail.askja.de with esmtpsa (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.63) (envelope-from ) id 1I5Tkb-000727-CA for gentoo-user@lists.gentoo.org; Mon, 02 Jul 2007 23:48:05 +0200 Received: from weird.wonkology.org (weird.wonkology.org [::ffff:192.168.1.4]) by zone.wonkology.org with esmtp; Mon, 02 Jul 2007 23:47:55 +0200 id 00030501.4689728B.000067C9 From: Alex Schuster Organization: Wonkology To: gentoo-user@lists.gentoo.org Subject: Re: [gentoo-user] Change the case of file names Date: Mon, 2 Jul 2007 23:47:54 +0200 User-Agent: KMail/1.9.5 References: <200707022159.27096.michaelkintzios@gmail.com> In-Reply-To: <200707022159.27096.michaelkintzios@gmail.com> Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-user@gentoo.org Reply-to: gentoo-user@lists.gentoo.org MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-15" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200707022347.54400.wonko@wonkology.org> X-Archives-Salt: 3f30d8ce-6ec6-430b-aa9e-b0fa3983f98d X-Archives-Hash: 8142bfb61eba1ff7f192337a7f1ee736 Mich writes: > I backed up my wife's WinXP fs using K3B and I used default settings > which unfortunately converted all file names to CAPITALS and shortened > them to 8 characters maximum, just like DOS would do. Is there a clever > way to change some of them back to lower case (in batches within given > directorates) so that she doesn't have to do it manually one by one? I > do not want to change the access times, only the filename case letters. Create a script like this, name it lowercase.sh or something, and call it with "lowercase file1 file2 dir1 dir2". I takes a list of files as arguments (use * for all), and also works for directories. So, "lowercase ." should convert all files and directories to lowercase. Put the script into your $PATH, or precede it by its path, e.g. ./lowercase. To test it before possible messing up (I just wrote this quickly) use the -t option: lowercase -t /path/to/your/files #!/bin/bash # parse options (-t only) while getopts "t" opt do case $opt in t ) test=true ;; * ) exit 1 esac done shift $(( OPTIND-1 )) # loop over arguments while (( $# )) do file=$1 if [[ -d $file ]] then # call myself $0 ${test:+-t} "$file"/* elif [[ -f $file ]] then # conversion to lowercase dir=$( dirname "$file" ) base=$( basename "$file" ) lower=$( echo "$base" | tr '[:upper:]' '[:lower:]' ) newfile=${dir:+$dir/}$lower [[ $file -ef $newfile ]] || ${test:+echo} mv -v "$file" "$newfile" else echo "File not found: '$1'" fi shift done Alex -- gentoo-user@gentoo.org mailing list