{"id":1087,"date":"2015-10-30T22:21:46","date_gmt":"2015-10-31T03:21:46","guid":{"rendered":"http:\/\/littlesvr.ca\/grumble\/?p=1087"},"modified":"2015-11-13T00:46:10","modified_gmt":"2015-11-13T05:46:10","slug":"printing-photos-with-bash","status":"publish","type":"post","link":"http:\/\/littlesvr.ca\/grumble\/2015\/10\/30\/printing-photos-with-bash\/","title":{"rendered":"Printing photos with bash"},"content":{"rendered":"<p>I&#8217;ve decided to finally print my photo collection and put the prints in albums like in the good old days.<\/p>\n<p>I spent a few days going through the files and picking what I want printed. I was not expecting to see that I will end up with 934 photos. But that&#8217;s not going to stop me, the albums I bought hold 500 photos each.<\/p>\n<p>The problem is that the photos are sorted by directory, one directory per set. And I don&#8217;t have any idea what order the actual prints will be in when I get them back from the printer.<\/p>\n<p>So to make sure I won&#8217;t spend another 8 hours sorting through 934 random-order photos I decided to rename them all so that the filename matches the file&#8217;s timestamp, and hope that the cameras&#8217; times were anywhere near accurate.<\/p>\n<p>To accomplish this task I had to write a crazy line of bash:<\/p>\n<p><code>i=0 find -type f | while read F; do cp \"$F\" \/home\/andrew\/temp\/Print\/by_date\/`ls -ld \"$F\" --time-style=\"+%Y-%m-%d_%H:%M:%S\" | cut -f 6 -d' '`_$i.jpg; i=$((i+1)) done<\/code><\/p>\n<p>Took me a half an hour to write that but it works. The i++ was necessary because about 80 photos had the same timestamp, I don&#8217;t know why.<\/p>\n<p>It turned filenames such as DSCF2345.JPG to 2007-05-02_12:04:34_351.jpg and just in case it put them all in one directory.<\/p>\n<p>I&#8217;ll add something to this post later if it turns out that wasn&#8217;t sufficient :)<\/p>\n<p>P.S. Turns out the service I used to print ignores filenames completely (it was some stupid Microsoft-based web app). It gave each photo a UUID and, annoyingly, sorted the thousand photos by UUID. Thanks, assholes :(<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I&#8217;ve decided to finally print my photo collection and put the prints in albums like in the good old days. I spent a few days going through the files and picking what I want printed. I was not expecting to see that I will end up with 934 photos. But that&#8217;s not going to stop &hellip; <\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[],"class_list":{"0":"entry","1":"post","2":"publish","3":"author-andrew","4":"post-1087","6":"format-standard","7":"category-opensource"},"_links":{"self":[{"href":"http:\/\/littlesvr.ca\/grumble\/wp-json\/wp\/v2\/posts\/1087","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/littlesvr.ca\/grumble\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/littlesvr.ca\/grumble\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/littlesvr.ca\/grumble\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"http:\/\/littlesvr.ca\/grumble\/wp-json\/wp\/v2\/comments?post=1087"}],"version-history":[{"count":4,"href":"http:\/\/littlesvr.ca\/grumble\/wp-json\/wp\/v2\/posts\/1087\/revisions"}],"predecessor-version":[{"id":1099,"href":"http:\/\/littlesvr.ca\/grumble\/wp-json\/wp\/v2\/posts\/1087\/revisions\/1099"}],"wp:attachment":[{"href":"http:\/\/littlesvr.ca\/grumble\/wp-json\/wp\/v2\/media?parent=1087"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/littlesvr.ca\/grumble\/wp-json\/wp\/v2\/categories?post=1087"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/littlesvr.ca\/grumble\/wp-json\/wp\/v2\/tags?post=1087"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}