zsh-users
 help / color / mirror / code / Atom feed
From: Bart Schaefer <schaefer@brasslantern.com>
To: zsh-users@zsh.org
Subject: Re: Half OT: Convenient way to a copy with path of single files
Date: Fri, 23 Sep 2011 23:38:40 -0700	[thread overview]
Message-ID: <110923233840.ZM24013@torch.brasslantern.com> (raw)
In-Reply-To: <20110924050925.GD16512@solfire>

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.


      reply	other threads:[~2011-09-24  6:38 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-09-24  5:09 meino.cramer
2011-09-24  6:38 ` Bart Schaefer [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=110923233840.ZM24013@torch.brasslantern.com \
    --to=schaefer@brasslantern.com \
    --cc=zsh-users@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).