#!/usr/bin/env zsh set -e fpath=($0:h:a/functions.zsh $fpath) dst=$2:a cd $1 [[ -n "$dst" ]] || { dst=encs ; dst=$dst:a } mkdir -p $dst autoload url-to-filename zmodload -F zsh/datetime b:strftime setopt EXTENDED_GLOB for new (new/*(N)) { while read line ; do [[ "$line" != "" ]] || break cols=(${(s: :)line}) [[ $cols[1] = "X-Enclosure:" ]] || continue url=$cols[2] [[ -n "$url" ]] fn=$(url-to-filename $url)-$(strftime %Y%m%d-%H%M%S) wget --output-document=$dst/$fn $url 2>&2 2>enc.log print $dst/$fn done < $new }