Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: somehow offtopic: looping filenames



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.



Messages sorted by: Reverse Date, Date, Thread, Author