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

Re: Trouble with zmv and extended globs



Dan Bullok <dan.zsh@xxxxxxxxxx> 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.



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