]> git.scottworley.com Git - picsort/blob - slurp-pics
Include referenced rename-to-date script
[picsort] / slurp-pics
1 #!/usr/bin/env bash
2
3 LEGACY='-oHostKeyAlgorithms=+ssh-dss'
4 sftp=( sftp -v -P 19362 -i .slurp-key -oConnectTimeout=4 $LEGACY )
5
6 seendir="slurp-seen"
7 while 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"/*
28 done < .slurp-hosts