]> git.scottworley.com Git - picsort/blame - slurp-pics
Move startup stuff to start()
[picsort] / slurp-pics
CommitLineData
967baf16 1#!/usr/bin/env bash
89e9c6b7 2
0605a43e
SW
3LEGACY='-oHostKeyAlgorithms=+ssh-dss'
4sftp=( sftp -v -P 19362 -i .slurp-key -oConnectTimeout=4 $LEGACY )
5
b8d03101 6seendir="slurp-seen"
89e9c6b7 7while read host path;do
b8d03101 8 outdir="slurp-$host-${path//\//,}"
89e9c6b7 9 {
20f5e5b6 10 mkdir -p "$outdir" "$seendir/$outdir"
89e9c6b7 11 echo "cd $path"
0605a43e 12 "${sftp[@]}" "slurp@$host" <<< "cd $path"$'\n'"ls -1" |
89e9c6b7
SW
13 sed 1,2d |
14 while read filename;do
348610a4 15 output_filename="$outdir/${filename/jpg/jpeg}"
20f5e5b6 16 if [[ -e "$output_filename" || -e "$seendir/$output_filename" ]];then
89e9c6b7
SW
17 echo "skipping $filename" >&2
18 else
19 echo "getting $filename" >&2
348610a4 20 echo "get -p $filename $output_filename"
89e9c6b7
SW
21 fi
22 done
0605a43e 23 } | "${sftp[@]}" "slurp@$host"
20f5e5b6
SW
24 for f in "$outdir"/*;do
25 touch "$seendir/$f"
26 done
27 rename-to-date "$outdir"/*
89e9c6b7 28done < .slurp-hosts