{"id":256,"date":"2004-12-27T01:49:32","date_gmt":"2004-12-27T06:49:32","guid":{"rendered":"http:\/\/ywwg.com\/wordpress\/?p=256"},"modified":"2004-12-27T01:49:32","modified_gmt":"2004-12-27T06:49:32","slug":"importing-photos-in-gnome","status":"publish","type":"post","link":"https:\/\/ywwg.com\/wordpress\/archives\/256","title":{"rendered":"importing photos in gnome"},"content":{"rendered":"<p>Thanks to HAL, dbus, and the whole alphabet soup, we can execute a script when we plug in our digital camera.  The default, running f-spot, doesn&#8217;t really do much good.  It doesn&#8217;t accomplish what it should, namely moving all the files from the camera to our hard drive.  Here&#8217;s a script I wrote that will actually do that, and it even has a progress bar!  It will also create new directories if you import multiple rounds of photos, to prevent overwriting of images.  Note that you need <a href=\"http:\/\/freshmeat.net\/projects\/zenity\">zenity<\/a> in order for this to work.<br \/>\n<!--more--><\/p>\n<pre>#!\/bin\/sh\n\n#change photo_root to the place where all the image directories should go\n#change camera_mount to the directory where the camera gets mounted\n#change the end of camera_dir to indicate where the photos lie on your flash card\n#change dirname to some expression that outputs what you'd like your directories to be called\n#  default is YYMMDD\n\nphoto_root=\"\/home\/owen\/Documents\/images\/photos\/raw\/\"\ncamera_mount=\"\/media\/NO_NAME\"\ncamera_dir=$camera_mount\"\/dcim\/101olymp\/\"\ndirname=`date +%y%m%d`\n\nif type 'zenity' 1>\/dev\/null 2>&1 ; then\n        echo fine\nelse\n        echo We need zenity\n        exit 1\nfi\n\nif [ `df |grep $camera_mount |wc -l` == \"0\" ] ; then\n\tzenity --error --text=\"Camera not mounted, exiting\"\n\texit 1\nfi\nnew_dir_made=0\nsuffix_val=0\nnew_dir=\"fart\"\nwhile [ $new_dir_made = 0 ] ; do\n\tif [ -d \"$photo_root\"$dirname\"-\"$suffix_val ] ; then\n\t\tlet suffix_val=suffix_val+1\n\telse\n\t\tmkdir \"$photo_root\"$dirname\"-\"$suffix_val\n\t\tnew_dir=\"$photo_root\"$dirname\"-\"$suffix_val\n\t\tnew_dir_made=1\n\tfi\ndone\n\nif [ ! -d $new_dir ] ; then\n\tzenity --error --text=\"Couldn't create new dir\"\n\texit 1\nelif [ $new_dir = \"fart\" ] ; then\n\tzenity --error --text=\"Couldn't create new dir\"\n\texit 1\nfi\n\nfile_count=`ls -1 $camera_dir | wc -l`\ni=0\n(\nfor file in $camera_dir\/* ; do\n\tlet value=i*100\/file_count\n\techo $value\n\tmv $file $new_dir\n\tlet i=i+1\n\tsleep 1\ndone\necho \"100\"\n) |\nzenity --progress \\\n          --title=\"Importing images\" \\\n          --text=\"Moving images to hard drive...\" \\\n          --percentage=0 \\\n          --auto-close\numount $camera_mount\nnautilus $new_dir<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Thanks to HAL, dbus, and the whole alphabet soup, we can execute a script when we plug in our digital camera. The default, running f-spot, doesn&#8217;t really do much good. It doesn&#8217;t accomplish what it should, namely moving all the files from the camera to our hard drive. Here&#8217;s a script I wrote that will &hellip; <a href=\"https:\/\/ywwg.com\/wordpress\/archives\/256\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;importing photos in gnome&#8221;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[13],"tags":[],"_links":{"self":[{"href":"https:\/\/ywwg.com\/wordpress\/wp-json\/wp\/v2\/posts\/256"}],"collection":[{"href":"https:\/\/ywwg.com\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ywwg.com\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ywwg.com\/wordpress\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/ywwg.com\/wordpress\/wp-json\/wp\/v2\/comments?post=256"}],"version-history":[{"count":0,"href":"https:\/\/ywwg.com\/wordpress\/wp-json\/wp\/v2\/posts\/256\/revisions"}],"wp:attachment":[{"href":"https:\/\/ywwg.com\/wordpress\/wp-json\/wp\/v2\/media?parent=256"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ywwg.com\/wordpress\/wp-json\/wp\/v2\/categories?post=256"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ywwg.com\/wordpress\/wp-json\/wp\/v2\/tags?post=256"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}