{"id":1540,"date":"2025-07-19T02:07:12","date_gmt":"2025-07-19T00:07:12","guid":{"rendered":"https:\/\/eiseler.de\/wordpress\/?p=1540"},"modified":"2025-07-19T02:07:14","modified_gmt":"2025-07-19T00:07:14","slug":"mac-foto-export-rename-files-or-directories","status":"publish","type":"post","link":"https:\/\/eiseler.de\/wordpress\/?p=1540","title":{"rendered":"Mac Foto export. Rename files or directories"},"content":{"rendered":"\n<p>As the Mac Foto export exports in directories like city, day, month year, I wanted it renamed. So I did a python script which reverses it. Now it is year-month-date town.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>import os\nimport re\nimport unicodedata\n\n# Zielverzeichnis\nverzeichnis = \"videos_von_iphone2\"\n\n# Monatsnamen auf Deutsch \u2192 Nummern\nmonate = {\n    \"Januar\": \"01\", \"Februar\": \"02\", \"M\u00e4rz\": \"03\", \"April\": \"04\",\n    \"Mai\": \"05\", \"Juni\": \"06\", \"Juli\": \"07\", \"August\": \"08\",\n    \"September\": \"09\", \"Oktober\": \"10\", \"November\": \"11\", \"Dezember\": \"12\"\n}\n\nprint(f\"\ud83d\udcc2 Starte Umbenennung im Verzeichnis: {verzeichnis}\\n\")\n\n# Alle Eintr\u00e4ge im Zielverzeichnis durchgehen\nfor eintrag in os.listdir(verzeichnis):\n    alter_pfad = os.path.join(verzeichnis, eintrag)\n\n    # Dateiname ohne Erweiterung (au\u00dfer bei Ordnern)\n    name, ext = os.path.splitext(eintrag)\n    if os.path.isdir(alter_pfad):\n        name = eintrag\n        ext = \"\"\n\n    print(f\"\ud83d\udd0d Pr\u00fcfe: {eintrag}\")\n\n    # Unicode-Leerzeichen etc. normalisieren\n    name_norm = unicodedata.normalize(\"NFKC\", name)\n\n    # REGEX: Ort mit Komma + Datum (z.\u202fB. \u201eOrt, 29. Mai 2025\u201c)\n    match_ort = re.match(r\"(.+),\\s*(\\d{1,2})\\.?\\s+(\\w+)\\s+(\\d{4})\", name_norm)\n\n    # REGEX: Nur Datum (z.\u202fB. \u201e29. Mai 2025\u201c)\n    match_kein_ort = re.match(r\"(\\d{1,2})\\.?\\s+(\\w+)\\s+(\\d{4})\", name_norm)\n\n    neuer_name = None\n\n    if match_ort:\n        ort = match_ort.group(1).strip()\n        tag = int(match_ort.group(2))\n        monat = match_ort.group(3)\n        jahr = match_ort.group(4)\n\n        if monat in monate:\n            neuer_name = f\"{jahr}-{monate&#91;monat]}-{tag:02d} {ort}{ext}\"\n        else:\n            print(f\"\u26a0\ufe0f  Unbekannter Monat: {monat}\")\n\n    elif match_kein_ort:\n        tag = int(match_kein_ort.group(1))\n        monat = match_kein_ort.group(2)\n        jahr = match_kein_ort.group(3)\n\n        if monat in monate:\n            neuer_name = f\"{jahr}-{monate&#91;monat]}-{tag:02d}{ext}\"\n        else:\n            print(f\"\u26a0\ufe0f  Unbekannter Monat: {monat}\")\n    else:\n        print(f\"\u26d4 Kein passendes Format erkannt.\")\n\n    # Umbenennen, falls m\u00f6glich\n    if neuer_name:\n        neuer_pfad = os.path.join(verzeichnis, neuer_name)\n\n        if alter_pfad == neuer_pfad:\n            print(\"\u2139\ufe0f  Name ist bereits korrekt.\")\n        else:\n            os.rename(alter_pfad, neuer_pfad)\n            print(f\"\u2705 Umbenannt: {eintrag} \u2192 {neuer_name}\")\n\n    print(\"\")  # Leerzeile zur Trennung<\/code><\/pre>\n<div class=\"sharedaddy sd-sharing-enabled\"><div class=\"robots-nocontent sd-block sd-social sd-social-icon-text sd-sharing\"><h3 class=\"sd-title\">Share this:<\/h3><div class=\"sd-content\"><ul><li class=\"share-facebook\"><a rel=\"nofollow noopener noreferrer\" data-shared=\"sharing-facebook-1540\" class=\"share-facebook sd-button share-icon\" href=\"https:\/\/eiseler.de\/wordpress\/?p=1540&amp;share=facebook\" target=\"_blank\" title=\"Click to share on Facebook\"><span>Facebook<\/span><\/a><\/li><li class=\"share-twitter\"><a rel=\"nofollow noopener noreferrer\" data-shared=\"sharing-twitter-1540\" class=\"share-twitter sd-button share-icon\" href=\"https:\/\/eiseler.de\/wordpress\/?p=1540&amp;share=twitter\" target=\"_blank\" title=\"Click to share on Twitter\"><span>Twitter<\/span><\/a><\/li><li class=\"share-linkedin\"><a rel=\"nofollow noopener noreferrer\" data-shared=\"sharing-linkedin-1540\" class=\"share-linkedin sd-button share-icon\" href=\"https:\/\/eiseler.de\/wordpress\/?p=1540&amp;share=linkedin\" target=\"_blank\" title=\"Click to share on LinkedIn\"><span>LinkedIn<\/span><\/a><\/li><li class=\"share-pocket\"><a rel=\"nofollow noopener noreferrer\" data-shared=\"\" class=\"share-pocket sd-button share-icon\" href=\"https:\/\/eiseler.de\/wordpress\/?p=1540&amp;share=pocket\" target=\"_blank\" title=\"Click to share on Pocket\"><span>Pocket<\/span><\/a><\/li><li class=\"share-end\"><\/li><\/ul><\/div><\/div><\/div>","protected":false},"excerpt":{"rendered":"<p>As the Mac Foto export exports in directories like city, day, month year, I wanted it renamed. So I did a python script which reverses it. Now it is year-month-date town.<\/p>\n<div class=\"sharedaddy sd-sharing-enabled\"><div class=\"robots-nocontent sd-block sd-social sd-social-icon-text sd-sharing\"><h3 class=\"sd-title\">Share this:<\/h3><div class=\"sd-content\"><ul><li class=\"share-facebook\"><a rel=\"nofollow noopener noreferrer\" data-shared=\"sharing-facebook-1540\" class=\"share-facebook sd-button share-icon\" href=\"https:\/\/eiseler.de\/wordpress\/?p=1540&amp;share=facebook\" target=\"_blank\" title=\"Click to share on Facebook\"><span>Facebook<\/span><\/a><\/li><li class=\"share-twitter\"><a rel=\"nofollow noopener noreferrer\" data-shared=\"sharing-twitter-1540\" class=\"share-twitter sd-button share-icon\" href=\"https:\/\/eiseler.de\/wordpress\/?p=1540&amp;share=twitter\" target=\"_blank\" title=\"Click to share on Twitter\"><span>Twitter<\/span><\/a><\/li><li class=\"share-linkedin\"><a rel=\"nofollow noopener noreferrer\" data-shared=\"sharing-linkedin-1540\" class=\"share-linkedin sd-button share-icon\" href=\"https:\/\/eiseler.de\/wordpress\/?p=1540&amp;share=linkedin\" target=\"_blank\" title=\"Click to share on LinkedIn\"><span>LinkedIn<\/span><\/a><\/li><li class=\"share-pocket\"><a rel=\"nofollow noopener noreferrer\" data-shared=\"\" class=\"share-pocket sd-button share-icon\" href=\"https:\/\/eiseler.de\/wordpress\/?p=1540&amp;share=pocket\" target=\"_blank\" title=\"Click to share on Pocket\"><span>Pocket<\/span><\/a><\/li><li class=\"share-end\"><\/li><\/ul><\/div><\/div><\/div>","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"spay_email":"","footnotes":"","jetpack_publicize_message":"","jetpack_is_tweetstorm":false},"categories":[1],"tags":[52,53,54],"class_list":["post-1540","post","type-post","status-publish","format-standard","hentry","category-uncategorized","tag-mac","tag-python","tag-script"],"jetpack_featured_media_url":"","jetpack_publicize_connections":[],"jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p8zAuQ-oQ","jetpack-related-posts":[{"id":1038,"url":"https:\/\/eiseler.de\/wordpress\/?p=1038","url_meta":{"origin":1540,"position":0},"title":"Raspberry pi & waveshare 2.7 e-ink Display & python","date":"11\/11\/2018","format":false,"excerpt":"Start with a headless raspberry, no need to connect monitor, keyboard:\u00a0https:\/\/raspberrypi.stackexchange.com\/questions\/10251\/prepare-sd-card-for-wifi-on-headless-pi Find the raspberry in your router and connect with ssh. Useullay steps are: sudo raspi-config sudo reboot (neu einloggen) sudo apt-get update -y sudo apt-get upgrade -y Here's some example python code for drawing text horizontal on the waveshare\u2026","rel":"","context":"In &quot;Hardware&quot;","img":{"alt_text":"","src":"https:\/\/i2.wp.com\/eiseler.de\/wordpress\/wp-content\/uploads\/2018\/11\/img_8466-e1541953811554.jpg?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]},{"id":155,"url":"https:\/\/eiseler.de\/wordpress\/?p=155","url_meta":{"origin":1540,"position":1},"title":"Android f\u00fcr Kinder - Schulweg\u00fcberwachung mit GPS","date":"28\/12\/2012","format":false,"excerpt":"Da meine Tochter schon mit 5 eingeschult wurde und auch alleine von der Schule zum Hort gehen muss \u00fcberlegte ich wie man dies mit Technik etwas sicherer machen kann. Ich m\u00f6chte hier nicht die Ethik des Einsatzes eines GPS-Trackers diskutieren, weise aber daraufhin, dass der Einsatz bei Erwachsenen ohne deren\u2026","rel":"","context":"In &quot;Android&quot;","img":{"alt_text":"","src":"https:\/\/i0.wp.com\/eiseler.de\/wordpress\/wp-content\/uploads\/2012\/12\/IMG_4118b-247x300.jpeg?resize=350%2C200","width":350,"height":200},"classes":[]},{"id":889,"url":"https:\/\/eiseler.de\/wordpress\/?p=889","url_meta":{"origin":1540,"position":2},"title":"NIU Gep\u00e4cktr\u00e4ger Tuning","date":"26\/01\/2018","format":false,"excerpt":"Der Niu wurde angeschafft um m\u00f6glichst schnell etwas zu besorgen, oder ein Kind irgendwo hin zu bringen. Im ersten Eintrag habe ich geschrieben, dass er das sehr gut kann. Was aber etwas st\u00f6rt, ist die geringe Gep\u00e4ck\/Einkaufsunterbringm\u00f6glichkeit. Zum Eislauftraining brauchen wir Schlittschuhe, Helm, Sch\u00fctzer, Trinkflasche, meinen Kaffee ;-), meine Kamera.\u2026","rel":"","context":"In &quot;Niu&quot;","img":{"alt_text":"","src":"https:\/\/i1.wp.com\/eiseler.de\/wordpress\/wp-content\/uploads\/2018\/01\/IMG_4184-e1516921468913-225x300.jpg?resize=350%2C200","width":350,"height":200},"classes":[]},{"id":1036,"url":"https:\/\/eiseler.de\/wordpress\/?p=1036","url_meta":{"origin":1540,"position":3},"title":"Connect Raspberry Pi & Arduino USB bidirectional","date":"25\/10\/2018","format":false,"excerpt":"How to connect an Arduino to a raspberry pi via USB bidirectional. The raspberry reads all from the serial and prints it. Next it reads a textile from a webpage and sends the text (one word) to serial, next a random car to the Arduino. Arduino got a LCD attached\u2026","rel":"","context":"Similar post","img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":1417,"url":"https:\/\/eiseler.de\/wordpress\/?p=1417","url_meta":{"origin":1540,"position":4},"title":"Python Tipps und Tricks","date":"25\/11\/2021","format":false,"excerpt":"https:\/\/www.youtube.com\/watch?v=qUeud6DvOWI","rel":"","context":"Similar post","img":{"alt_text":"","src":"https:\/\/i1.wp.com\/img.youtube.com\/vi\/qUeud6DvOWI\/0.jpg?resize=350%2C200","width":350,"height":200},"classes":[]},{"id":533,"url":"https:\/\/eiseler.de\/wordpress\/?p=533","url_meta":{"origin":1540,"position":5},"title":"Canon Selphy + Mac Yosemite Driver","date":"31\/12\/2014","format":false,"excerpt":"Shame on Canon not updating their Selphy printer driver for Mac Yosemite, But there is a solution. Christian Spuller created a Yosemite driver based on the mavericks driver: Download here ----- Kein Druckertreiber f\u00fcr Canon Selphy unter Yosemite. L\u00f6sung. Dicussed here: .","rel":"","context":"In &quot;Mac&quot;","img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]}],"_links":{"self":[{"href":"https:\/\/eiseler.de\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/1540","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/eiseler.de\/wordpress\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/eiseler.de\/wordpress\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/eiseler.de\/wordpress\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/eiseler.de\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1540"}],"version-history":[{"count":1,"href":"https:\/\/eiseler.de\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/1540\/revisions"}],"predecessor-version":[{"id":1541,"href":"https:\/\/eiseler.de\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/1540\/revisions\/1541"}],"wp:attachment":[{"href":"https:\/\/eiseler.de\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1540"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/eiseler.de\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1540"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/eiseler.de\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1540"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}