Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: capitalizing file names



Phil Pennock <zsh-workers+phil.pennock@xxxxxxxxxxxx> wrote:
> % zmv '(*).(*)' '${(C)1}.${2:u}'
> zmv: error(s) in substitution:
> file exists: Alexy_070411_1971.DNG
> (Probably the same file, owing to file system limitations.)
> 
> In the definition of zmv: [[ $f != $g && $f -ef $g ]]
> $f is the original filename, $g is the generated filename and they're
> the same file (-ef, equal file).

Presumably if the files really are equivalent, it's safe to attempt
to mv in the hope that the file system knows what it's doing.  We've
already tested for $f = $g at this point.

Unfortunately, Cygwin mv (6.4) still barfs on this, presumably because it
hasn't been told about case-insensitive case-preserving file systems.
However, this ought at least to be no worse than what zmv was outputting.
It would be possible to use an intermediate, but doing it safely in general
is a pain (and no longer atomic, which wasn't guaranteed before but would
have been the case anyway on a lot of systems).  It turns out you can get
it to work with "zmodload zsh/files", because zsh's mv doesn't do that
test, but that has other effects.  Now with local feature support...

Index: Functions/Misc/zmv
===================================================================
RCS file: /cvsroot/zsh/zsh/Functions/Misc/zmv,v
retrieving revision 1.11
diff -u -r1.11 zmv
--- Functions/Misc/zmv	16 Jan 2004 15:29:27 -0000	1.11
+++ Functions/Misc/zmv	14 May 2007 17:42:22 -0000
@@ -262,13 +262,8 @@
     continue
   elif [[ -n $from[$g] && ! -d $g ]]; then
     errs=($errs "$f and $from[$g] both map to $g")
-  elif [[ -f $g && -z $opt_f ]]; then
-    if [[ $f != $g && $f -ef $g ]]; then
-      errs=($errs "file exists: $g
-(Probably the same file, owing to file system limitations.)")
-    else
-      errs=($errs "file exists: $g")
-    fi
+  elif [[ -f $g && -z $opt_f && ! ($f -ef $g) ]]; then
+    errs=($errs "file exists: $g")
   fi
   from[$g]=$f
   to[$f]=$g


-- 
Peter Stephenson <pws@xxxxxxx>                  Software Engineer
CSR PLC, Churchill House, Cambridge Business Park, Cowley Road
Cambridge, CB4 0WZ, UK                          Tel: +44 (0)1223 692070


To access the latest news from CSR copy this link into a web browser:  http://www.csr.com/email_sig.php

To get further information regarding CSR, please visit our Investor Relations page at http://ir.csr.com/csr/about/overview



Messages sorted by: Reverse Date, Date, Thread, Author