From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 8101 invoked by alias); 24 Sep 2011 06:38:55 -0000 Mailing-List: contact zsh-users-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Users List List-Post: List-Help: X-Seq: 16414 Received: (qmail 29949 invoked from network); 24 Sep 2011 06:38:51 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received-SPF: none (ns1.primenet.com.au: domain at closedmail.com does not designate permitted sender hosts) From: Bart Schaefer Message-id: <110923233840.ZM24013@torch.brasslantern.com> Date: Fri, 23 Sep 2011 23:38:40 -0700 In-reply-to: <20110924050925.GD16512@solfire> Comments: In reply to meino.cramer@gmx.de "Half OT: Convenient way to a copy with path of single files" (Sep 24, 7:09am) References: <20110924050925.GD16512@solfire> X-Mailer: OpenZMail Classic (0.9.2 24April2005) To: zsh-users@zsh.org Subject: Re: Half OT: Convenient way to a copy with path of single files MIME-version: 1.0 Content-type: text/plain; charset=us-ascii On Sep 24, 7:09am, meino.cramer@gmx.de wrote: } } mycp /home/user/A/B/C/D/files.txt /home/A/B/other/. } } results in : } } /home/A/B/other/C/D/files.txt Something along these lines should work: autoload -Uz zmv zmv -C '/(home)/user/(A)/(B)/(C)/(D)/(files.txt)' '/$1/$2/$3/other/$4/$5/$6' Unfortunately that doesn't translate well to replacing "files.txt" with an arbitrary subtree pattern, because parenthesized glob patterns can only refer to files within a single directory. However, the special case of a recursive glob will work if you make use of the -w option: zmv -wC '/(home)/user/(A)/(B)/(C)/(D)/**/*(.txt)' '/$1/$2/$3/other/$4/$5$6$7' Here $5 contains everything found by **/ _including_ the trailing slash, and $7 contains the .txt extension; hence no slashes in $5$6$7.