* Re: Trouble with zmv and extended globs
2005-10-19 0:27 Trouble with zmv and extended globs Dan Bullok
@ 2005-10-19 1:00 ` Philippe Troin
2005-10-19 1:07 ` Dan Bullok
2005-10-19 6:25 ` Bart Schaefer
2 siblings, 0 replies; 5+ messages in thread
From: Philippe Troin @ 2005-10-19 1:00 UTC (permalink / raw)
To: Dan Bullok; +Cc: Zsh Users
Dan Bullok <dan.zsh@bullok.com> writes:
> I'm having some trouble with zmv.
> Suppose I have a bunch of python scripts in a directory, and none of them end
> in .py. I want to give them all a proper extension, so I try:
> zmv -n '(*)(#qe,file ${REPLY}|grep "python script",)' '$1.py'
> This works as I expected it to.
> However, if I have a bunch of python scripts in several subdirectories of
> varying depths, I try:
> zmv -n '(**/con*)(#qe,file ${REPLY}|grep "python script",)' '$1.py'
> which gives me the following error:
> zmv:238: bad pattern: (*/*)(#qe,file ${REPLY}|grep python,)
>
> I've also tried:
> zmv -n '(*/*(#qe,file ${REPLY}|grep python,))' '$1.py'
> which doesn't work either.
>
> I'm sure I'm missing something, because it seems like it should be possible.
> Can someone help me with this, please? I've been trying various permutations
> for over an hour, and I'm REALLY stuck.
There's an obscure rule in matching that basically says that you
cannot combine the ** and *** glob operators with other glob operators
within the same path segment.
Meaning that ** must be separated from other glob operators.
zmv -n '(**)/(con*)(#qe,file ${REPLY}|grep "python script",)' '$1/$2.py'
works.
However it will not glob files in the current directory. Then you
want this:
zmv -n '(*/)#(con*)(#qe,file ${REPLY}|grep "python script",)' '$1$2.py'
** is an shortcut for (*/)#
Phil.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Trouble with zmv and extended globs
2005-10-19 0:27 Trouble with zmv and extended globs Dan Bullok
2005-10-19 1:00 ` Philippe Troin
@ 2005-10-19 1:07 ` Dan Bullok
2005-10-19 6:25 ` Bart Schaefer
2 siblings, 0 replies; 5+ messages in thread
From: Dan Bullok @ 2005-10-19 1:07 UTC (permalink / raw)
To: Zsh Users
The typo gremlin got me. See corrections below.
On Tuesday 18 October 2005 19:27, Dan Bullok wrote:
> I'm having some trouble with zmv.
> Suppose I have a bunch of python scripts in a directory, and none of them
> end in .py. I want to give them all a proper extension, so I try:
> zmv -n '(*)(#qe,file ${REPLY}|grep "python script",)' '$1.py'
> This works as I expected it to.
> However, if I have a bunch of python scripts in several subdirectories of
> varying depths, I try:
> zmv -n '(**/con*)(#qe,file ${REPLY}|grep "python script",)' '$1.py'
zmv -n '(**/*)(#qe,file ${REPLY}|grep "python script",)' '$1.py'
> which gives me the following error:
> zmv:238: bad pattern: (*/*)(#qe,file ${REPLY}|grep python,)
zmv:238: bad pattern: (**/*)(#qe,file ${REPLY}|grep python,)
>
> I've also tried:
> zmv -n '(*/*(#qe,file ${REPLY}|grep python,))' '$1.py'
zmv -n '(**/*(#qe,file ${REPLY}|grep python,))' '$1.py'
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Trouble with zmv and extended globs
2005-10-19 0:27 Trouble with zmv and extended globs Dan Bullok
2005-10-19 1:00 ` Philippe Troin
2005-10-19 1:07 ` Dan Bullok
@ 2005-10-19 6:25 ` Bart Schaefer
2005-10-19 8:14 ` Peter Stephenson
2 siblings, 1 reply; 5+ messages in thread
From: Bart Schaefer @ 2005-10-19 6:25 UTC (permalink / raw)
To: Zsh Users
On Oct 18, 7:27pm, Dan Bullok wrote:
} varying depths, I try:
} zmv -n '(**/con*)(#qe,file ${REPLY}|grep "python script",)' '$1.py'
} which gives me the following error:
} zmv:238: bad pattern: (*/*)(#qe,file ${REPLY}|grep python,)
Philippe's answer was almost the correct one.
** is not a shortcut for (*/)#. **/ is a shortcut for (*/)#. The slash
must be there, and must immediately follow the two stars, and there must
not be anything but a slash [or open paren] preceding the two stars, or
they do not have special meaning (and are the same as one star).
In fact, Philippe's second example should work:
zmv -n '(*/)#(con*)(#qe,file ${REPLY}|grep "python script",)' '$1$2.py'
As should:
zmv -n '(**/)(con*)(#qe,file $REPLY | grep "python script",)' '$1$2.py'
You might want to use "grep -q", though.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Trouble with zmv and extended globs
2005-10-19 6:25 ` Bart Schaefer
@ 2005-10-19 8:14 ` Peter Stephenson
0 siblings, 0 replies; 5+ messages in thread
From: Peter Stephenson @ 2005-10-19 8:14 UTC (permalink / raw)
To: zsh-users
Bart Schaefer <schaefer@brasslantern.com> wrote:
> As should:
>
> zmv -n '(**/)(con*)(#qe,file $REPLY | grep "python script",)' '$1$2.py'
The file zmv itself indicates that this is the right way to do it. As the
manual entry in zshcontrib indicates, the file is a little more verbose
than the manual entry.
--
Peter Stephenson <pws@csr.com> Software Engineer
CSR PLC, Churchill House, Cambridge Business Park, Cowley Road
Cambridge, CB4 0WZ, UK Tel: +44 (0)1223 692070
This message has been scanned for viruses by BlackSpider MailControl - www.blackspider.com
^ permalink raw reply [flat|nested] 5+ messages in thread