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

more fun with parameter expansion



This is for someone who wants to take a directory tree and convert all
the filenames (and directory names) to lowercase, replacing spaces
with underscores.  It presumes that you are using GNU mv and have
MARK_DIRS set.  I'm sure that someone can make it more efficient.

for i (*(/N)) {mv -v "$i" "${(L)i:gs/ /_/}"}
for i (*/**/*(/N)) {mv -v "${${(L)i%/*/}:gs/ /_/}/${${${i#*/}%/}##*/}" "${(L)i:gfor i (**/*(N^/)) {mv -v "${i}" "${(L)i:gs/ /_/}"}



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