Skip to content

t-kageyama/iphone-photo-archiver

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

iphone-photo-archiver

iPhone / iPad で撮影された写真/ビデオファイルを外付けHDD / SSD に移動させるためのツール。 本ツールでは、ビデオファイルは iPhone / iPad で撮影された MOV ファイルを前提としています。

ツールの概要

このツールは、iPhone / iPad で撮影した写真・ビデオファイルを、Mac を介して外付け HDD / SSD に移動させるためのスクリプトです。

  • 写真・ビデオファイルは iPhone / iPad で撮影されたものを前提としています。

  • 移動先には /年/月/日 の形式でディレクトリを作成し、そこにファイルを移動します。

  • 日付の取得方法は以下のとおりです。

    • 画像ファイル:EXIF 情報の撮影日時
    • ビデオファイル:ファイルの作成日時
  • 画像ファイルについては、EXIF 情報から 緯度・経度情報を取得します。

  • 緯度・経度情報が存在する場合、Python スクリプトを介して 地名情報を取得する Reverse Geocoding API を呼び出し、移動先ディレクトリに keyword.txt ファイルを作成して情報を記録します。keyword.txt は日付ディレクトリごとに作成され、情報は追記形式で記録されます。

この仕組みにより、 iPhone / iPad のストレージ容量を空けつつ、日付・場所で後から探しやすい形で写真を保管できます。

ツール動作の前提条件

以下の環境が必要です。

  • Python 3.x
    • 最近の macOS には標準でインストールされています。
    • インストールされていない場合は、各自でインストールしてください。
  • exiftool
    • brew を使用したインストール方法が一般的です。
    • brew の使用方法については、各自インターネット等でお調べください。
    • 他のインストール方法を利用する場合は、その手順に従ってください。

一般的な使用方法

  1. photo_mv.shファイルの9行目の /YOUR_SAVE_IMAGES_EXTERNAL_PATH を、あなたの外付け HDD / SSD 内の保存先パスに変更してください。

  2. iPhone / iPad から、写真・ビデオファイルを AirDrop を使って Mac に転送します。通常、ファイルは ~/Downloads ディレクトリに保存されます。

  3. 任意の空のディレクトリを作成し、そこに転送したファイルを移動します。 このツールは、ファイル名が IMG_ で始まる画像・ビデオファイルをすべて移動対象とします。 (必須ではありませんが、誤操作防止のため、この方法を推奨します)

  4. Macでターミナルを開きます。

  5. 写真・ビデオファイルをコピーしたディレクトリに移動します。

  6. photo_mv.sh を実行します。 photo_mv.sh は、カレントディレクトリ内にある IMG_ で始まる画像・ビデオファイルを、 移動先ディレクトリ内に /年/月/日 のサブディレクトリを作成して移動させます。

補足

このスクリプトを ~/Downloads 内で直接実行することも可能ですが、推奨されません。 このスクリプトは IMG_ で始まるファイルのみを処理しますが、~/Downloads には無関係なファイルが含まれていることがよくあります。 安全のため、専用のフォルダを使用することをお勧めします。

Reverse Geocoding API(OpenStreetMap / Nominatim)

本ツールは、画像ファイルに GPS 情報(緯度・経度)が含まれている場合、OpenStreetMap の Nominatim Reverse API を使って地名情報を取得し、keyword.txt に記録します。

  • Reverse API 例:https://nominatim.openstreetmap.org/reverse?lat=${lat}&lon=${lon}&format=json
  • Nominatim(nominatim.openstreetmap.org)には利用ポリシーがあります。大量・高速なアクセスは推奨されません。
  • 公開 API を利用する場合は、識別可能な User-Agent を付けることが推奨されます(本ツールでも User-Agent を設定しています)。

クレジット(Attribution)

OpenStreetMap データの利用にはクレジット表記が必要です。 本ツールは keyword.txt にライセンス(licence)文字列を記録します(例:Data © OpenStreetMap contributors...)。

注意(Rate limit / 大量処理)

nominatim.openstreetmap.org は「たまに使う」用途向けの公開サービスです。継続的・大量の処理を行う場合は、利用ポリシーに従い、代替手段(自前運用・商用API等)を検討してください。


iphone-photo-archiver (English)

A simple tool to move photos and videos taken on iPhone / iPad to an external HDD / SSD via macOS.

This tool assumes that video files are MOV files recorded on iPhone / iPad.

Overview

This tool is a shell and Python script to move photos and videos taken on iPhone / iPad to an external HDD / SSD via macOS.

  • Photos and videos are assumed to be taken on iPhone / iPad.
  • Files are moved into directories organized by /YYYY/MM/DD.
  • Date information is determined as follows:
    • Image files: DateTimeOriginal from EXIF metadata
    • Video files: File creation date
  • For image files, GPS latitude and longitude are extracted from EXIF metadata.
  • If GPS information exists, a reverse geocoding API is called via a Python script. Location information is stored in a keyword.txt file in the destination directory.

keyword.txt is created per date directory, and information is appended (not overwritten).

This allows you to free up iPhone / iPad storage while keeping photos organized by date and location.

Requirements

  • Python 3.x
    • Recent versions of macOS include Python 3 by default.
    • If it is not installed, please install it yourself.
  • exiftool
    • Installing via brew is recommended.
    • Please search the internet for information on how to use brew.
    • If you use another installation method, follow those instructions.

Basic Usage

  1. Edit line 9 of photo_mv.sh and set /YOUR_SAVE_IMAGES_EXTERNAL_PATH to the destination path on your external HDD / SSD.

  2. Transfer photos and videos from iPhone / iPad to macOS using AirDrop. Files are usually saved in ~/Downloads.

  3. Create an empty directory and move the transferred files into it. This tool processes only files whose names start with IMG_. (This step is recommended to avoid accidental file moves.)

  4. Open Terminal and move to the directory containing the files.

  5. Run photo_mv.sh.

Notes

It is possible to run this script directly in ~/Downloads, but this is not recommended. Although the script only processes files starting with IMG_, ~/Downloads often contains unrelated files. For safety, using a dedicated directory is recommended.

Reverse Geocoding API (OpenStreetMap / Nominatim)

This tool uses the OpenStreetMap Nominatim Reverse API to retrieve location names when GPS information (latitude / longitude) is available in image EXIF metadata. The retrieved information is recorded in keyword.txt.

  • Reverse API example: https://nominatim.openstreetmap.org/reverse?lat=${lat}&lon=${lon}&format=json

  • The public Nominatim service (nominatim.openstreetmap.org) has a usage policy. High-volume or high-frequency requests are not recommended.

  • When using the public API, a clearly identifiable User-Agent is recommended. (This tool sets a User-Agent header.)

Attribution

Use of OpenStreetMap data requires proper attribution. This tool records the license string (e.g. Data © OpenStreetMap contributors...) in keyword.txt.

Notes on rate limits / bulk processing

The public Nominatim service is intended for occasional use. For continuous or bulk processing, please follow the usage policy and consider alternative approaches (self-hosted Nominatim or commercial APIs).

About

A simple tool to move photos and videos taken on iPhone / iPad to an external HDD / SSD via macOS.

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors