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