* Half OT: Convenient way to a copy with path of single files
@ 2011-09-24 5:09 meino.cramer
2011-09-24 6:38 ` Bart Schaefer
0 siblings, 1 reply; 2+ messages in thread
From: meino.cramer @ 2011-09-24 5:09 UTC (permalink / raw)
To: zsh-users
Hi,
I am looking for a convenient way to copy a handful
of files as follows ("mycp" stands for what ever I
have to use to accomplish the copy):
mycp /home/user/A/B/C/D/files.txt /home/A/B/other/.
results in :
/home/A/B/other/C/D/files.txt
where 'files.txt' is a placeholder for everything which my
be matched by regular expressions inclusive furthere directories,
symlinks etc...
Is there a alreadu a command in the treasure of zsh or do I have
to script something?
Thank you very much in advance for any help!
Best regards,
mcc
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: Half OT: Convenient way to a copy with path of single files
2011-09-24 5:09 Half OT: Convenient way to a copy with path of single files meino.cramer
@ 2011-09-24 6:38 ` Bart Schaefer
0 siblings, 0 replies; 2+ messages in thread
From: Bart Schaefer @ 2011-09-24 6:38 UTC (permalink / raw)
To: zsh-users
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.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2011-09-24 6:38 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-09-24 5:09 Half OT: Convenient way to a copy with path of single files meino.cramer
2011-09-24 6:38 ` Bart Schaefer
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).