{"id":2434,"date":"2021-11-20T20:46:50","date_gmt":"2021-11-20T11:46:50","guid":{"rendered":"https:\/\/mattyan.net\/blog\/?p=2434"},"modified":"2021-11-20T20:46:50","modified_gmt":"2021-11-20T11:46:50","slug":"%e5%a3%8a%e3%82%8c%e3%81%9fsd%e3%82%ab%e3%83%bc%e3%83%89%e3%81%8b%e3%82%89%e5%86%99%e7%9c%9f%e3%82%92%e5%be%a9%e6%97%a7%e3%81%97%e3%81%a6%e3%81%bf%e3%81%9f","status":"publish","type":"post","link":"https:\/\/mattyan.net\/blog\/?p=2434","title":{"rendered":"\u58ca\u308c\u305fSD\u30ab\u30fc\u30c9\u304b\u3089\u5199\u771f\u3092\u5fa9\u65e7\u3057\u3066\u307f\u305f"},"content":{"rendered":"<p>\u6025\u306bSD\u30ab\u30fc\u30c9\u304c\u7834\u640d\u3057\u305f\u306e\u3067\u9811\u5f35\u3063\u3066\u5199\u771f\u3092\u5fa9\u65e7\u3057\u305f\u3002<\/p>\n<p><!--more--><\/p>\n<p>\u9ad8\u5c3e\u99c5\u3067\u30c8\u30e9\u30f3\u30b9\u30a4\u30fc\u30c8\u56db\u5b63\u5cf6\u3092\u64ae\u3063\u3066\u300c\u3055\u3041\u5199\u771f\u3092twitter\u306b\u4e0a\u3052\u3088\u3046\u300d\u3068\u30ab\u30e1\u30e9\u304b\u3089\u53d6\u308a\u51fa\u3057\u305fSD\u30ab\u30fc\u30c9\u3092\u643a\u5e2f\u306b\u3064\u306a\u3044\u3060\u3068\u3053\u308d\u300c\u30d5\u30a9\u30fc\u30de\u30c3\u30c8\u306e\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u300d\u306e\u30a8\u30e9\u30fc\u30e1\u30c3\u30bb\u30fc\u30b8\u3002\u30ab\u30e1\u30e9\u306b\u623b\u3057\u3066\u307f\u3066\u3082\u300c\u30ab\u30fc\u30c9\u304c\u30d5\u30a9\u30fc\u30de\u30c3\u30c8\u3055\u308c\u3066\u307e\u305b\u3093\u300d\u3068\u30a8\u30e9\u30fc\u304c\u51fa\u3066\u8d77\u52d5\u305b\u305a\u2026\u2026<\/p>\n<p>\u3053\u308c\u306fSD\u30ab\u30fc\u30c9\u304c\u58ca\u308c\u305f\u3068\u601d\u3044\u3001\u305d\u306e\u5f8c\u306e\u4e88\u5b9a\u5168\u90e8\u6f70\u3057\u3066\u5b9f\u5bb6\u306b\u5e30\u5b85\u3002\u5e78\u3044Linux\u5165\u308c\u305fASUS T100TA\u3092\u6301\u3063\u3066\u304d\u3066\u305f\u306e\u3067\u76f4\u3061\u306b\u30c7\u30fc\u30bf\u6551\u51fa\u958b\u59cb\u3002<\/p>\n<h2 id=\"\u6551\u51fa\u524d\u306e\u30c7\u30fc\u30bf\u5438\u3044\u51fa\u3057\">\u6551\u51fa\u524d\u306e\u30c7\u30fc\u30bf\u5438\u3044\u51fa\u3057<\/h2>\n<p>\u307e\u305a\u306fdd\u30b3\u30de\u30f3\u30c9\u3067SD\u30ab\u30fc\u30c9\u306e\u30c7\u30fc\u30bf\u3092\u5438\u3044\u51fa\u3057\u3002<\/p>\n<pre class=\"sh\"><code class=\"\" data-line=\"\">sudo dd if=\/dev\/sdb of=image.dd.orig bs=512 conv=noerror,sync<\/code><\/pre>\n<p>\u6570\u5341\u5206\u5f85\u3063\u306630GB\u306e\u30a4\u30e1\u30fc\u30b8\u30d5\u30a1\u30a4\u30eb\u306e\u51fa\u6765\u4e0a\u304c\u308a\u3002\u4e00\u5fdc\u30b3\u30d4\u30fc\u3068\u3063\u3066\u64cd\u4f5c\u958b\u59cb\u3002<\/p>\n<h2 id=\"\u5fa9\u5143\u4f5c\u696d\">\u5fa9\u5143\u4f5c\u696d<\/h2>\n<p>\u307e\u305a\u306fmount -t vfat\u3057\u3066\u307f\u308b\u3082\u30a8\u30e9\u30fc<\/p>\n<pre class=\"sh\"><code class=\"\" data-line=\"\">sudo mount -t vfat image.dd.orig \/mnt\/sd\nmount: \/mnt\/sd: wrong fs type, bad option, bad superblock on \/dev\/loop13, missing codepage or helper program, or other error.<\/code><\/pre>\n<p>\u6b21\u306bfsck\u3057\u3066\u307f\u308b\u3082\u3001\u3084\u3063\u3071\u308a\u30a8\u30e9\u30fc<\/p>\n<pre class=\"sh\"><code class=\"\" data-line=\"\">sudo fsck.vfat image.dd.orig\nfsck.fat 4.2 (2021-01-31)\nLogical sector size is zero.<\/code><\/pre>\n<p>\u6b63\u76f4\u3001\u60f3\u5b9a\u5185\u3002<\/p>\n<p>\u6b21\u306b\u3001\u4e88\u3081\u5e30\u308a\u306e\u96fb\u8eca\u3067\u8abf\u3079\u3066\u305ftestdisk\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u3066\u3001\u540c\u68b1\u306ephotorec\u3067\u5fa9\u5143<\/p>\n<pre class=\"sh\"><code class=\"\" data-line=\"\">photorec image.dd.orig<\/code><\/pre>\n<p>\u53d6\u308a\u51fa\u3057\u5143\u30c7\u30d0\u30a4\u30b9(\u30a4\u30e1\u30fc\u30b8\u30d5\u30a1\u30a4\u30eb)\u3068\u304b\u51fa\u529b\u5148\u3068\u304b\u30d5\u30a1\u30a4\u30eb\u30b7\u30b9\u30c6\u30e0\u3068\u304b\u8a2d\u5b9a\u3057\u3066\u5b9f\u884c\u3002 \u2026\u2026\u7d42\u308f\u3089\u306a\u3044\u3002\u3088\u304f\u898b\u305f\u3089reading sector\u304c\u3042\u308b\u7a0b\u5ea6\u9032\u3093\u3060\u3042\u3068\u623b\u3063\u3066\u308b\u3002<\/p>\n<p>\u540c\u3058\u3068\u3053\u308d\u3092\u5c11\u306a\u304f\u3068\u30824\u9031\u3057\u3066\u308b\u3053\u3068\u3092\u78ba\u8a8d\u3057\u3066\u51e6\u7406\u3092\u505c\u6b62\u3002\u5e78\u3044\u3053\u3053\u6700\u8fd1\u64ae\u3063\u305f\u5199\u771f\u306f\u5fa9\u5143\u3067\u304d\u3066\u305f\u306e\u3067\u6b8b\u308a\u306f\u8ae6\u3081\u305f\u3002<\/p>\n<h2 id=\"\u30d5\u30a1\u30a4\u30eb\u540d\u518d\u8a2d\u5b9a\">\u30d5\u30a1\u30a4\u30eb\u540d\u518d\u8a2d\u5b9a<\/h2>\n<p>photorec\u306f\u30bb\u30af\u30bf\u3092\u898b\u3066\u30d5\u30a1\u30a4\u30eb\u3092\u62fe\u3063\u3066\u304f\u308b\u4ed5\u69d8\u3089\u3057\u304f\u3001\u30d5\u30a1\u30a4\u30eb\u540d\u306f\u5fa9\u5143\u3055\u308c\u306a\u3044\u3002 \u8d05\u6ca2\u8a00\u3063\u3066\u3089\u308c\u306a\u3044\u306e\u3067\u3001\u307e\u305a\u306fexif\u60c5\u5831\u3092\u3082\u3068\u306b\u64ae\u5f71\u65e5\u3054\u3068\u306b\u4ed5\u5206\u3051<\/p>\n<pre class=\"lang:python\"><code class=\"\" data-line=\"\">from PIL import Image\nimport re\nimport os.path\nimport shutil\ndef get_dirname(file):\n    image = Image.open(file)\n    if image._getexif():\n        dir = re.sub(&#039;(\\d{4}):(\\d{2}):(\\d{2}).*&#039;, r&#039;\\1\\2\\3&#039;,image._getexif()[36868])\n        return dir\ndef get_filename(dir):\n    file_count = sum(os.path.isfile(os.path.join(dir, name)) for name in os.listdir(dir))\n    return &#039;REC_{:05d}.JPG&#039;.format(file_count + 1)\ndef copy(file):\n    dir = get_dirname(file)\n    if dir is None:\n        print(f&#039;{file} does not have exif&#039;)\n        return\n    if not os.path.exists(dir):\n        os.mkdir(dir)\n    filename = get_filename(dir)\n    shutil.copy(file, os.path.join(dir, filename))\n    print(os.path.join(dir, filename))\nlist = os.listdir(&#039;.&#039;)\nfor file in list:\n    if &#039;.jpg&#039; in file.lower():\n        print(file)\n        copy(file)<\/code><\/pre>\n<p>\u3053\u308c\u3060\u3068\u64ae\u5f71\u6642\u523b\u30ac\u30f3\u7121\u8996\u306e\u4e26\u3073\u9806\u306b\u306a\u308b\u306e\u3067\u3001\u4e00\u65e6\u4ed5\u5206\u3051\u3057\u3066\u304b\u3089\u64ae\u5f71\u6642\u523b\u3067\u30bd\u30fc\u30c8<\/p>\n<pre class=\"lang:python\"><code class=\"\" data-line=\"\">from PIL import Image\nimport re\nimport os\nimport shutil\nimport datetime\nlist = os.listdir(&#039;.&#039;)\nfile_list = []\nfor file in list:\n    if &#039;.JPG&#039; in file:\n        image = Image.open(file)\n        file_list.append({\n            &#039;name&#039;: file,\n            &#039;date&#039;: datetime.datetime.strptime(image._getexif()[36868], &#039;%Y:%m:%d %H:%M:%S&#039;)\n        })\nsorted_list = sorted(file_list, key = lambda o: o[&#039;date&#039;])\nindex = 1\nfor file in sorted_list:\n    file_path = os.path.join(&#039;sort&#039;, &#039;REC_{:05d}.JPG&#039;.format(index))\n    print(file_path)\n    shutil.copy(file[&#039;name&#039;], file_path)\n    index = index + 1\n<\/code><\/pre>\n<p>\u3082\u306e\u3059\u3054\u304f\u96d1\u306a\u30b9\u30af\u30ea\u30d7\u30c8\u3060\u3051\u3069\u3001\u3053\u308c\u3067\u30bd\u30fc\u30c8\u3082\u5b8c\u4e86(1\u79d2\u4ee5\u5185\u306b\u64ae\u3089\u308c\u305f\u5199\u771f\u306f\u9806\u756a\u304c\u5165\u308c\u66ff\u308f\u308b\u3051\u3069\u3001\u305d\u3053\u306f\u3082\u3046\u6687\u306a\u3068\u304d\u306b\u624b\u3067\u5bfe\u51e6)\u3002\u4eca\u65e5\u64ae\u3063\u305f\u5199\u771f\u306f\u5fa9\u5143\u3067\u304d\u305f\u3063\u307d\u3044\u3002<\/p>\n<p>\u58ca\u308c\u305fSD\u30ab\u30fc\u30c9\u306f\u2026\u2026\u30d5\u30a9\u30fc\u30de\u30c3\u30c8\u3059\u308c\u3070\u4f7f\u3048\u308b\u3093\u3060\u308d\u3046\u3051\u3069\u3001FlashAir\u3060\u304b\u3089\u4e0b\u624b\u306b\u30d5\u30a9\u30fc\u30de\u30c3\u30c8\u3059\u308b\u3068\u7121\u7ddaLAN\u6a5f\u80fd\u304c\u4f7f\u3048\u306a\u304f\u306a\u308b\u3093\u3060\u3088\u306a\u3041\u2026\u2026\u3082\u3046\u7121\u7ddaLAN\u306f\u4f7f\u3063\u3066\u306a\u3044\u3057\u3001\u666e\u901a\u306eSD\u30ab\u30fc\u30c9\u3068\u4ea4\u63db\u3059\u308b\u304b\u2026\u2026<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6025\u306bSD\u30ab\u30fc\u30c9\u304c\u7834\u640d\u3057\u305f\u306e\u3067\u9811\u5f35\u3063\u3066\u5199\u771f\u3092\u5fa9\u65e7\u3057\u305f\u3002<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[],"class_list":["post-2434","post","type-post","status-publish","format-standard","hentry","category-4"],"_links":{"self":[{"href":"https:\/\/mattyan.net\/blog\/index.php?rest_route=\/wp\/v2\/posts\/2434","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/mattyan.net\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mattyan.net\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mattyan.net\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mattyan.net\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2434"}],"version-history":[{"count":0,"href":"https:\/\/mattyan.net\/blog\/index.php?rest_route=\/wp\/v2\/posts\/2434\/revisions"}],"wp:attachment":[{"href":"https:\/\/mattyan.net\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2434"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mattyan.net\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2434"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mattyan.net\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2434"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}