Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: removing spaces from a file name
- X-seq: zsh-users 12503
- From: Peter Stephenson <pws@xxxxxxx>
- To: zsh-users@xxxxxxxxxx
- Subject: Re: removing spaces from a file name
- Date: Wed, 30 Jan 2008 11:41:41 +0000
- In-reply-to: <Xns9A3574A71769Dzzappergmailcom@xxxxxxxxxxxx>
- Mailing-list: contact zsh-users-help@xxxxxxxxxx; run by ezmlm
- References: <Xns9A3574A71769Dzzappergmailcom@xxxxxxxxxxxx>
zzapper wrote:
> Hi
> I still dislike spaces in file names:-
>
> mv Licence\ to\ Print\ Money.pdf !#^:gs/ //
>
> Is there a better/other way?
I use zmv for this; it's distributed with the shell and documented in
zshcontrib, so see that for more information.
autoload -U zmv
zmv '(* *)' '${1// /_}'
This acts on all files in the current directory with at least one space
in the name (the first pattern---note the quotes). The parenthesis can
be referred to in the second argument as $1. The substitution does
basically what you did with the history, except that I replace the space
with a "_". Obviously, you can turn this into a function.
--
Peter Stephenson <pws@xxxxxxx> Software Engineer
CSR PLC, Churchill House, Cambridge Business Park, Cowley Road
Cambridge, CB4 0WZ, UK Tel: +44 (0)1223 692070
Messages sorted by:
Reverse Date,
Date,
Thread,
Author