Re: Unix-ify File Names

2007-04-28 Thread Masatran, R. Deepak
* Masatran, R. Deepak [EMAIL PROTECTED] 2007-04-17 Since I frequently receive files from Microsoft Windows users, is there any utility to unix-ify file names, that is, use lower case exclusively, use hyphen as separator, etc.? I wrote the script below just now. Kindly give comments

Re: Unix-ify File Names

2007-04-24 Thread Frank Terbeck
Daniel Barclay [EMAIL PROTECTED]: Frank Terbeck wrote: Daniel Barclay [EMAIL PROTECTED]: Frank Terbeck wrote: Daniel B. [EMAIL PROTECTED]: [...] For example, Emacs' tags files use commas as delimiters, and (last I knew) don't have an escape/encoding mechansim for representing a comma _in_ a

Re: Unix-ify File Names

2007-04-23 Thread Daniel Barclay
Frank Terbeck wrote: Daniel Barclay [EMAIL PROTECTED]: Frank Terbeck wrote: Daniel B. [EMAIL PROTECTED]: Frank Terbeck wrote: Mike McClain [EMAIL PROTECTED]: Frank Terbeck [EMAIL PROTECTED] wrote: ... ... people think spaces are bad in filenames. (They are not bad, ... In what

Re: Unix-ify File Names

2007-04-21 Thread Mike McClain
Frank Terbeck [EMAIL PROTECTED] wrote: find is just the tool you want to use for recursive actions on files (or specialized actions, like sorting). find is an external program, but it does not take a file list as argument, which makes it the ultimate choice. I took your advice to heart

Re: Unix-ify File Names

2007-04-21 Thread Thomas Jollans
Masatran, R. Deepak wrote: Since I frequently receive files from Microsoft Windows users, is there any utility to unix-ify file names, that is, use lower case exclusively, use hyphen as separator, etc.? I wrote this little zsh script once; it unixifies all file names in the current and sub

Re: Unix-ify File Names

2007-04-21 Thread Frank Terbeck
Thomas Jollans [EMAIL PROTECTED]: [...] zsh, yay! :-) Just a few remarks. #!/bin/zsh FS= IFS, I suppose. But: Why do you set it? for f in **/* for i in ./**/* # make f=./$f unneeded below. do #required for files in the current dir. f=./$f #dir of file fp1=${f%/*}/

Re: Unix-ify File Names

2007-04-21 Thread Thomas Jollans
Frank Terbeck wrote: Thomas Jollans [EMAIL PROTECTED]: [...] zsh, yay! :-) Just a few remarks. #!/bin/zsh FS= IFS, I suppose. But: Why do you set it? ugh... good question. I wrote this ages ago ;-) for f in **/* for i in ./**/* # make f=./$f unneeded below. do

Re: Unix-ify File Names

2007-04-21 Thread Octavio Alvarez
On Sat, 21 Apr 2007 05:26:40 -0700, Thomas Jollans [EMAIL PROTECTED] wrote: FS= IFS, I suppose. But: Why do you set it? ugh... good question. I wrote this ages ago ;-) To make sure spaces in filenames don't break them apart? -- Octavio.

Re: Unix-ify File Names

2007-04-21 Thread Frank Terbeck
Octavio Alvarez [EMAIL PROTECTED]: On Sat, 21 Apr 2007 05:26:40 -0700, Thomas Jollans [EMAIL PROTECTED] wrote: FS= IFS, I suppose. But: Why do you set it? ugh... good question. I wrote this ages ago ;-) To make sure spaces in filenames don't break them apart? Not an issue in default

Re: Unix-ify File Names

2007-04-19 Thread Mike McClain
Frank Terbeck [EMAIL PROTECTED] wrote: a) `ls *` is an _external_ process. b) it breaks on filenames with spaces (and other special characters). c) people commonly use 'ls --color' or 'ls -F' aliases for ls. There is _no_ reason why 'ls' should ever be used to generate file lists for loops of

Re: Unix-ify File Names

2007-04-19 Thread Daniel Barclay
Frank Terbeck wrote: Daniel B. [EMAIL PROTECTED]: Frank Terbeck wrote: Mike McClain [EMAIL PROTECTED]: Frank Terbeck [EMAIL PROTECTED] wrote: for FILE in `ls *$1` ; do ... b) it breaks on filenames with spaces (and other special characters). ... Using 'for i in `ls *`'-type loops

Re: Unix-ify File Names

2007-04-19 Thread Frank Terbeck
Daniel Barclay [EMAIL PROTECTED]: Frank Terbeck wrote: Daniel B. [EMAIL PROTECTED]: Frank Terbeck wrote: Mike McClain [EMAIL PROTECTED]: Frank Terbeck [EMAIL PROTECTED] wrote: for FILE in `ls *$1` ; do ... b) it breaks on filenames with spaces (and other special characters). ...

Re: Unix-ify File Names

2007-04-19 Thread Ken Irving
On Thu, Apr 19, 2007 at 09:05:56PM +0200, Frank Terbeck wrote: Daniel Barclay [EMAIL PROTECTED]: Some commands do provide fully general mechanisms. (For example, find's -print0 and xargs' -0 option can handle any possible file pathname, including one with newline characters.) However,

Re: Unix-ify File Names

2007-04-18 Thread Frank Terbeck
Mike McClain [EMAIL PROTECTED]: Frank Terbeck [EMAIL PROTECTED] wrote: for FILE in `ls *$1` ; do Please don't teach beginners to do for loops like this. It's broken in various ways. Just do: for FILE in *$1 ; do Being a self taught script writer I just have to ask what are

Re: Unix-ify File Names

2007-04-18 Thread Daniel B.
Frank Terbeck wrote: Mike McClain [EMAIL PROTECTED]: Frank Terbeck [EMAIL PROTECTED] wrote: for FILE in `ls *$1` ; do ... b) it breaks on filenames with spaces (and other special characters). ... Using 'for i in `ls *`'-type loops breaks this and is one of the main reasons why

Re: Unix-ify File Names

2007-04-18 Thread H.S.
Frank Terbeck wrote: b) it breaks on filenames with spaces (and other special characters). While newlines and other special characters might be rather weird for filenames, spaces are perfectly okay and normal in filenames. Using 'for i in `ls *`'-type loops breaks this and is one

Re: Unix-ify File Names

2007-04-18 Thread Frank Terbeck
Daniel B. [EMAIL PROTECTED]: Frank Terbeck wrote: Mike McClain [EMAIL PROTECTED]: Frank Terbeck [EMAIL PROTECTED] wrote: for FILE in `ls *$1` ; do ... b) it breaks on filenames with spaces (and other special characters). ... Using 'for i in `ls *`'-type loops breaks this and is one of

Re: Unix-ify File Names

2007-04-18 Thread Frank Terbeck
H.S. [EMAIL PROTECTED]: Frank Terbeck wrote: b) it breaks on filenames with spaces (and other special characters). While newlines and other special characters might be rather weird for filenames, spaces are perfectly okay and normal in filenames. Using 'for i in `ls *`'-type

Re: Unix-ify File Names

2007-04-17 Thread Frank Terbeck
Jeff D [EMAIL PROTECTED]: On Tue, 17 Apr 2007, Masatran, R. Deepak wrote: Since I frequently receive files from Microsoft Windows users, is there any utility to unix-ify file names, that is, use lower case exclusively, use hyphen as separator, etc.? [...] #!/bin/sh #change spaces

Re: Unix-ify File Names

2007-04-17 Thread Octavio Alvarez
On Mon, 16 Apr 2007 20:24:57 -0700, Masatran, R. Deepak [EMAIL PROTECTED] wrote: Since I frequently receive files from Microsoft Windows users, is there any utility to unix-ify file names, that is, use lower case exclusively, use hyphen as separator, etc.? I use something like

Re: Unix-ify File Names

2007-04-17 Thread Leonid Grinberg
Or, in Perl (might as well): #!/usr/bin/perl -w use strict; opendir(DIR, system('pwd')); my @files = readdir(DIR); closedir(DIR); my $new_name; foreach (@files) { $new_name = lc($_); $new_name =~ s/\ /\-/g; system('mv -i $_ $new_name'); } -- To UNSUBSCRIBE, email to [EMAIL PROTECTED]

Re: Unix-ify File Names

2007-04-17 Thread Leonid Grinberg
opendir(DIR, system('pwd')); Sorry, that should be: opendir(DIR, `pwd`); ` returns output. system() does not. -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of unsubscribe. Trouble? Contact [EMAIL PROTECTED]

Re: Unix-ify File Names

2007-04-17 Thread Ken Irving
On Tue, Apr 17, 2007 at 09:23:19AM -0700, Leonid Grinberg wrote: opendir(DIR, system('pwd')); Sorry, that should be: opendir(DIR, `pwd`); ` returns output. system() does not. Or just use '.' as the directory name. -- Ken Irving -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a

Re: Unix-ify File Names

2007-04-17 Thread Mike McClain
Frank Terbeck [EMAIL PROTECTED] wrote: for FILE in `ls *$1` ; do Please don't teach beginners to do for loops like this. It's broken in various ways. Just do: for FILE in *$1 ; do Being a self taught script writer I just have to ask what are the 'various ways' in which the first

Re: Unix-ify File Names

2007-04-17 Thread Roberto C . Sánchez
On Tue, Apr 17, 2007 at 03:36:26PM -0700, Mike McClain wrote: Frank Terbeck [EMAIL PROTECTED] wrote: for FILE in `ls *$1` ; do Please don't teach beginners to do for loops like this. It's broken in various ways. Just do: for FILE in *$1 ; do Being a self taught script

Re: Unix-ify File Names

2007-04-17 Thread Jeff D
On Tue, 17 Apr 2007, Roberto C. S?nchez wrote: On Tue, Apr 17, 2007 at 03:36:26PM -0700, Mike McClain wrote: Frank Terbeck [EMAIL PROTECTED] wrote: for FILE in `ls *$1` ; do Please don't teach beginners to do for loops like this. It's broken in various ways. Just do: for FILE in *$1 ;

Unix-ify File Names

2007-04-16 Thread Masatran, R. Deepak
Since I frequently receive files from Microsoft Windows users, is there any utility to unix-ify file names, that is, use lower case exclusively, use hyphen as separator, etc.? -- Masatran, R. Deepak http://research.iiit.ac.in/~masatran/ pgpBGtYS9v62i.pgp Description: PGP signature

Re: Unix-ify File Names

2007-04-16 Thread Jeff D
On Tue, 17 Apr 2007, Masatran, R. Deepak wrote: Since I frequently receive files from Microsoft Windows users, is there any utility to unix-ify file names, that is, use lower case exclusively, use hyphen as separator, etc.? -- Masatran, R. Deepak http://research.iiit.ac.in/~masatran