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