* Renaming thingy
@ 2007-05-14 17:02 meino.cramer
2007-05-14 17:24 ` Peter Stephenson
0 siblings, 1 reply; 2+ messages in thread
From: meino.cramer @ 2007-05-14 17:02 UTC (permalink / raw)
To: zsh-users
Hi,
I have a directory tree with different directories
on different levels.
There are files scattered around there, some of then
are named *.JPG.
I want to rename them, starting at the root of that tree
to *.jpg.
Furthermore some of the directories contain spaces in
their names. I want to replace the spaces by underscores.
Is there a compact way to accomplish this with zsh?
Thanks a lot for any helpful hint in advance!
Keep zshing!
mcc
--
Please don't send me any Word- or Powerpoint-Attachments
unless it's absolutely neccessary. - Send simply Text.
See http://www.gnu.org/philosophy/no-word-attachments.html
In a world without fences and walls nobody needs gates and windows.
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: Renaming thingy
2007-05-14 17:02 Renaming thingy meino.cramer
@ 2007-05-14 17:24 ` Peter Stephenson
0 siblings, 0 replies; 2+ messages in thread
From: Peter Stephenson @ 2007-05-14 17:24 UTC (permalink / raw)
To: zsh-users
meino.cramer@gmx.de wrote:
> Hi,
>
> I have a directory tree with different directories
> on different levels.
> There are files scattered around there, some of then
> are named *.JPG.
> I want to rename them, starting at the root of that tree
> to *.jpg.
> Furthermore some of the directories contain spaces in
> their names. I want to replace the spaces by underscores.
>
> Is there a compact way to accomplish this with zsh?
Do it in two stages.
autoload -U zmv
zmv '(**/)(*).JPG' '$1$2.jpg'
zmv '(**/)(*)(#q/)' '$1${2// /_}'
This is guaranteed to be depth first. So first it renames .JPG files,
then it renames directories starting with the end component. This
should mean all the generated "mv"s operate on existing file names.
I think.
--
Peter Stephenson <pws@csr.com> Software Engineer
CSR PLC, Churchill House, Cambridge Business Park, Cowley Road
Cambridge, CB4 0WZ, UK Tel: +44 (0)1223 692070
To access the latest news from CSR copy this link into a web browser: http://www.csr.com/email_sig.php
To get further information regarding CSR, please visit our Investor Relations page at http://ir.csr.com/csr/about/overview
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2007-05-14 17:25 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-05-14 17:02 Renaming thingy meino.cramer
2007-05-14 17:24 ` Peter Stephenson
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).