]> git.scottworley.com Git - picsort/blob - slurp-pics
533c680f56cf1856778d3122277a8ed9f0b59b21
[picsort] / slurp-pics
1 #!/bin/bash
2
3 LEGACY='-oHostKeyAlgorithms=+ssh-dss'
4 sftp=( sftp -v -P 19362 -i .slurp-key -oConnectTimeout=4 $LEGACY )
5
6 while read host path;do
7 outdir="slurp-$host"
8 seendir="slurp-seen"
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"/*
28 done < .slurp-hosts