* 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
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
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
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
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
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%/*}/
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
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.
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
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
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
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).
...
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,
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
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
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
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
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
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
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
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]
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]
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
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
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
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 ;
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
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
28 matches
Mail list logo