{"id":66,"date":"2011-07-13T22:14:52","date_gmt":"2011-07-13T20:14:52","guid":{"rendered":"http:\/\/prout-prout.net\/blog\/?p=66"},"modified":"2013-08-01T18:40:04","modified_gmt":"2013-08-01T16:40:04","slug":"script-pour-sauvegarder-les-photos","status":"publish","type":"post","link":"https:\/\/xn--jrme-bpa1e.net\/blog\/post\/66\/script-pour-sauvegarder-les-photos\/","title":{"rendered":"Script pour sauvegarder les photos"},"content":{"rendered":"<p>[bash]<br \/>\n#!\/bin\/sh<\/p>\n<p>#set -x<\/p>\n<p>basedirectory=\u00a0\u00bb\/media\/CANON_DC\/DCIM\/\u00a0\u00bb<br \/>\nsshinfo=\u00a0\u00bbxxx@yyy.com\u00a0\u00bb<br \/>\nserverdir=\u00a0\u00bb\/home\/xxx\/photos\/\u00a0\u00bb<\/p>\n<p>processfile ()<br \/>\n{<br \/>\n  extension=`echo \u00ab\u00a0${2}\u00a0\u00bb | awk -F . &lsquo;{ print $NF }&rsquo;  | tr &lsquo;[:upper:]&rsquo; &lsquo;[:lower:]&rsquo;`<br \/>\n  if [ \u00ab\u00a0${extension}\u00a0\u00bb = \u00ab\u00a0jpg\u00a0\u00bb -o \u00ab\u00a0${extension}\u00a0\u00bb = \u00ab\u00a0jpeg\u00a0\u00bb ] ; then<br \/>\n    localcksum=`cksum \u00ab\u00a0${1}${2}\u00a0\u00bb | awk &lsquo;{ print $1 \u00a0\u00bb \u00a0\u00bb $2 }&rsquo;`<br \/>\n    serverfilename=`echo \u00ab\u00a0${localcksum}\u00a0\u00bb | awk &lsquo;{ print $1 }&rsquo;`<br \/>\n    serverfilename=\u00a0\u00bb${serverfilename}.${extension}\u00a0\u00bb<br \/>\n    echo \u00ab\u00a0${serverallcksum}\u00a0\u00bb | grep \u00ab\u00a0${localcksum} ${serverdir}${serverfilename}\u00a0\u00bb &gt; \/dev\/null<br \/>\n    if [ \u00ab\u00a0${?}\u00a0\u00bb = \u00ab\u00a01\u00a0\u00bb ] ; then<br \/>\n      scp -p \u00ab\u00a0${1}${2}\u00a0\u00bb \u00ab\u00a0${sshinfo}\u00a0\u00bb:\u00a0\u00bb${serverdir}${serverfilename}\u00a0\u00bb<br \/>\n      stat=`stat -c %y \u00ab\u00a0${1}${2}\u00a0\u00bb`<br \/>\n      ssh \u00ab\u00a0${sshinfo}\u00a0\u00bb touch -d \u00ab\u00a0${stat}\u00a0\u00bb \u00ab\u00a0${serverdir}${serverfilename}\u00a0\u00bb<br \/>\n    fi<br \/>\n  else<br \/>\n    echo \u00ab\u00a0skiping ${2} because of extension: ${extension}\u00a0\u00bb<br \/>\n  fi<br \/>\n}<\/p>\n<p>scandir()<br \/>\n{<br \/>\n  echo \u00ab\u00a0scan ${1}\u00a0\u00bb<br \/>\n  for myfile in `ls ${1}`<br \/>\n  do<br \/>\n    if [ \u00ab\u00a0${1}\u00a0\u00bb = \u00ab\u00a0.\u00a0\u00bb -o \u00ab\u00a0${1}\u00a0\u00bb = \u00ab\u00a0..\u00a0\u00bb ] ; then<br \/>\n      echo \u00ab\u00a0skip ${1}\u00a0\u00bb<br \/>\n    elif [ -d \u00ab\u00a0${1}${myfile}\/\u00a0\u00bb ] ; then<br \/>\n      scandir \u00ab\u00a0${1}${myfile}\/\u00a0\u00bb<br \/>\n    else<br \/>\n      processfile \u00ab\u00a0${1}\u00a0\u00bb \u00ab\u00a0${myfile}\u00a0\u00bb<br \/>\n    fi<br \/>\n  done<br \/>\n}<\/p>\n<p>serverallcksum=`ssh \u00ab\u00a0${sshinfo}\u00a0\u00bb cksum \u00ab\u00a0${serverdir}*\u00a0\u00bb`<\/p>\n<p>scandir \u00ab\u00a0${basedirectory}\u00a0\u00bb<br \/>\n[\/bash]<\/p>\n","protected":false},"excerpt":{"rendered":"<p>[bash] #!\/bin\/sh #set -x basedirectory=\u00a0\u00bb\/media\/CANON_DC\/DCIM\/\u00a0\u00bb sshinfo=\u00a0\u00bbxxx@yyy.com\u00a0\u00bb serverdir=\u00a0\u00bb\/home\/xxx\/photos\/\u00a0\u00bb processfile () { extension=`echo \u00ab\u00a0${2}\u00a0\u00bb | awk -F . &lsquo;{ print $NF }&rsquo; | tr &lsquo;[:upper:]&rsquo; &lsquo;[:lower:]&rsquo;` if [ \u00ab\u00a0${extension}\u00a0\u00bb = \u00ab\u00a0jpg\u00a0\u00bb -o \u00ab\u00a0${extension}\u00a0\u00bb = \u00ab\u00a0jpeg\u00a0\u00bb ] ; then localcksum=`cksum \u00ab\u00a0${1}${2}\u00a0\u00bb | awk &hellip; <a href=\"https:\/\/xn--jrme-bpa1e.net\/blog\/post\/66\/script-pour-sauvegarder-les-photos\/\">Continuer la lecture <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-66","post","type-post","status-publish","format-standard","hentry","category-non-classe"],"_links":{"self":[{"href":"https:\/\/xn--jrme-bpa1e.net\/blog\/wp-json\/wp\/v2\/posts\/66","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/xn--jrme-bpa1e.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/xn--jrme-bpa1e.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/xn--jrme-bpa1e.net\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/xn--jrme-bpa1e.net\/blog\/wp-json\/wp\/v2\/comments?post=66"}],"version-history":[{"count":9,"href":"https:\/\/xn--jrme-bpa1e.net\/blog\/wp-json\/wp\/v2\/posts\/66\/revisions"}],"predecessor-version":[{"id":338,"href":"https:\/\/xn--jrme-bpa1e.net\/blog\/wp-json\/wp\/v2\/posts\/66\/revisions\/338"}],"wp:attachment":[{"href":"https:\/\/xn--jrme-bpa1e.net\/blog\/wp-json\/wp\/v2\/media?parent=66"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/xn--jrme-bpa1e.net\/blog\/wp-json\/wp\/v2\/categories?post=66"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/xn--jrme-bpa1e.net\/blog\/wp-json\/wp\/v2\/tags?post=66"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}