public inbox for gentoo-user@lists.gentoo.org
 help / color / mirror / Atom feed
From: Mick <michaelkintzios@gmail.com>
To: gentoo-user@lists.gentoo.org
Subject: Re: [gentoo-user] Change the case of file names
Date: Sun, 8 Jul 2007 22:18:03 +0100	[thread overview]
Message-ID: <200707082218.12807.michaelkintzios@gmail.com> (raw)
In-Reply-To: <200707022347.54400.wonko@wonkology.org>

[-- Attachment #1: Type: text/plain, Size: 2019 bytes --]

On Monday 02 July 2007 22:47, Alex Schuster wrote:
> 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

Thanks Alex, I was trying your script, but just like Etaoin's script it does 
not go beyond level 1 in the directory.  All the subdirectories and files 
within them stay in Capital Case.

How can I change it to recursively look into the directory?
-- 
Regards,
Mick

[-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --]

  reply	other threads:[~2007-07-08 21:24 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-07-02 20:59 [gentoo-user] Change the case of file names Mick
2007-07-02 21:08 ` Hemmann, Volker Armin
2007-07-02 21:25   ` Mick
2007-07-03  2:42     ` Hemmann, Volker Armin
2007-07-02 21:38   ` Albert Hopkins
2007-07-03  2:44     ` Hemmann, Volker Armin
2007-07-02 21:19 ` Etaoin Shrdlu
2007-07-02 21:47 ` Alex Schuster
2007-07-08 21:18   ` Mick [this message]
2007-07-08 23:00     ` Alex Schuster
2007-07-09  8:00     ` Etaoin Shrdlu
2007-07-02 22:08 ` Willie Wong
2007-07-03  5:51   ` Mick
2007-07-04  7:03     ` Kent Fredric
2007-07-04 18:44       ` Mick
2007-07-04 20:18         ` Kent Fredric

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200707082218.12807.michaelkintzios@gmail.com \
    --to=michaelkintzios@gmail.com \
    --cc=gentoo-user@lists.gentoo.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox