euglug.org

[Eug-lug] Subject: Copying, moving, whatever… using wildcards in destination : wc2fn.py

작성자

카테고리:



horstWed Nov 3 00:11:48 PST 2004

> Date: Tue, 2 Nov 2004 08:12:27 -0800
> From: Bob Miller <kbob at jogger-egg.com>
> To: EugLUG <euglug at euglug.org>
  ...
>> Let's assume a slightly more complicated example, like renaming
>> files *BAR*FOO9[0-9].HTM from the 1990s to *bare*foot_199[0-9].html
> 	/usr/bin/rename BAR bare *BAR*FOO9[0-9].HTM
> 	/usr/bin/rename FOO9 foot_199 *bare*FOO9[0-9].HTM
> 	/usr/bin/rename .HTM .html *bare*foot_199[0-9].HTM
>
  This is actually not as bad as I thought.
  But if kbob writes it it's probably also as good as it gets.

However, the ELF(*) version of 'rename' Bob is using is not a standard 
Unix tool: I don't have it on our Sun workstations, or the BSD boxes I am 
working on (including this account, where I am sending my email from). One 
of the points in my original post was, to easily move your 'customized & 
empowered environment' to wherever you go; scripts (.py .pl .sh) are more 
likely to be portable than binaries, i.e. I can't mess around in my ISP's 
lib area.
  So, rename(ELF) is not really 'doing it the Unix way'(for those who care) 
--it's a specialized program, and as such on the same level as wc2fn. That 
said, rename(ELF) only covers a small subset of what wc2fn can do (it's 
missing the generic command and program wraps wc2fn offers, as well the 
specialized(=handy) symlinks applications any user can customize fairly 
easily).
  Beyond those limitations, there are same potentially dangerous aspects to 
rename(ELF): my ' 1 Januari 2000	' man pages don't give any hint 
how directories and symlinks are handled. Well, I tested: directories were 
affected as well as symlinks (but rendered dangling/broken). In contrasts, 
wc2fn currently excludes dirs and symlinks, has a very brief discussion on 
the subject, and puts the subject on the TODO list. Moreover, if you run 
wc2fn with the -v (verbose) option you are informed about which files are 
skipped and why.

About rename(ELF): to avoid confusion, the ELF binary is different from 
the perl version of 'rename' Hal and I were talking about earlier. The 
perl version uses regExpr, as I recall.

  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
It's interesting, my original post had several aspects:
  One aspect was how to perform specific file system operation; we saw a 
number of interesting alternatives and code examples.
  Another, more general, aspect was how/if we can/should integrate the 
common parts of any of those 'rename' or whatever applications into one 
shell tool that can handle the, what I call source:destination pairs 
treatment, plus a hook to apply any command to such pairs.

  I am obviously biased regarding the latter ........... Horst