Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Half OT: Convenient way to a copy with path of single files
- X-seq: zsh-users 16414
- From: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- To: zsh-users@xxxxxxx
- Subject: Re: Half OT: Convenient way to a copy with path of single files
- Date: Fri, 23 Sep 2011 23:38:40 -0700
- In-reply-to: <20110924050925.GD16512@solfire>
- List-help: <mailto:zsh-users-help@zsh.org>
- List-id: Zsh Users List <zsh-users.zsh.org>
- List-post: <mailto:zsh-users@zsh.org>
- Mailing-list: contact zsh-users-help@xxxxxxx; run by ezmlm
- References: <20110924050925.GD16512@solfire>
On Sep 24, 7:09am, meino.cramer@xxxxxx 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.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author