Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: somehow offtopic: looping filenames
- X-seq: zsh-users 16776
- From: Stephen Blott <smblott@xxxxxxxxx>
- To: zsh-users@xxxxxxx
- Subject: Re: somehow offtopic: looping filenames
- Date: Tue, 21 Feb 2012 12:35:36 +0000
- Authentication-results: mr.google.com; spf=pass (google.com: domain of smblott@xxxxxxxxx designates 10.180.8.226 as permitted sender) smtp.mail=smblott@xxxxxxxxx; dkim=pass header.i=smblott@xxxxxxxxx
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=date:from:to:subject:message-id:references:mime-version :content-type:content-disposition:in-reply-to:user-agent; bh=stuShOEhdO+G7pc0NEGvQkPwwRsniS7qF4QyfFry8cU=; b=DSownrmJMUquKYZxoSKqpptoADDdjEhIVatilgn1WcUR22IQyaNnkEmWGrC2c3Gxs3 tYNhet9qFpAwRQb4s4ohBs7HZg6sfp3Y9f0iBzLZNRQ8ut29A+AmpMrxIWacgTru9sOL /OgDe0N+yYnOGnXT8DEVOrPjunpRJS3Gr35FQ=
- In-reply-to: <120220110530.ZM450@torch.brasslantern.com>
- 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: <20120220181650.GA11514@solfire> <120220110530.ZM450@torch.brasslantern.com>
On Mon, Feb 20, 2012 at 11:05:30AM -0800, Bart Schaefer wrote:
> On Feb 20, 7:16pm, meino.cramer@xxxxxx wrote:
> }
> } I habe a loop like this:
> }
> } for fn *
> } do
> } flac $fn
> } done
> }
> } Unfortunately, some file have 'illegal' filenames
> } which parts flac sees as unknown commmand options or as
> } two file and the loop fails.
>
> Try this:
>
> for fn *
> do
> flac $fn:a
> done
>
> The :a modifier expands $fn into a full path including removing any
> mentions of "./" and "../". Think of it as a clean "$PWD/$fn".
>
> If you don't have a recent-enough zsh for :a to be supported or it is
> for some reason important to avoid the full path, try
>
> flac ${${fn:h}-.}/${fn:t}
>
> If that's still confusing it because e.g. you have SH_WORD_SPLIT turned
> on, wrap the expression in double quotes.
>
---end quoted text---
Or:
ls | tr '\n' '\0' | xargs -0 -n 1 flac --
If you're using Gnu xargs then you might need the -r/--no-run-if-empty flag
too.
Steve
Messages sorted by:
Reverse Date,
Date,
Thread,
Author