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の使用方法については、各自インターネット等でお調べください。- 他のインストール方法を利用する場合は、その手順に従ってください。
-
photo_mv.shファイルの9行目の
/YOUR_SAVE_IMAGES_EXTERNAL_PATHを、あなたの外付け HDD / SSD 内の保存先パスに変更してください。 -
iPhone / iPad から、写真・ビデオファイルを AirDrop を使って Mac に転送します。通常、ファイルは
~/Downloadsディレクトリに保存されます。 -
任意の空のディレクトリを作成し、そこに転送したファイルを移動します。 このツールは、ファイル名が
IMG_で始まる画像・ビデオファイルをすべて移動対象とします。 (必須ではありませんが、誤操作防止のため、この方法を推奨します) -
Macでターミナルを開きます。
-
写真・ビデオファイルをコピーしたディレクトリに移動します。
-
photo_mv.shを実行します。photo_mv.shは、カレントディレクトリ内にある IMG_ で始まる画像・ビデオファイルを、 移動先ディレクトリ内に/年/月/日のサブディレクトリを作成して移動させます。
このスクリプトを ~/Downloads 内で直接実行することも可能ですが、推奨されません。
このスクリプトは IMG_ で始まるファイルのみを処理しますが、~/Downloads には無関係なファイルが含まれていることがよくあります。
安全のため、専用のフォルダを使用することをお勧めします。
本ツールは、画像ファイルに 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 を設定しています)。
OpenStreetMap データの利用にはクレジット表記が必要です。
本ツールは keyword.txt にライセンス(licence)文字列を記録します(例:Data © OpenStreetMap contributors...)。
nominatim.openstreetmap.org は「たまに使う」用途向けの公開サービスです。継続的・大量の処理を行う場合は、利用ポリシーに従い、代替手段(自前運用・商用API等)を検討してください。
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.
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.txtfile 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.
- Python 3.x
- Recent versions of macOS include Python 3 by default.
- If it is not installed, please install it yourself.
- exiftool
- Installing via
brewis recommended. - Please search the internet for information on how to use
brew. - If you use another installation method, follow those instructions.
- Installing via
-
Edit line 9 of
photo_mv.shand set/YOUR_SAVE_IMAGES_EXTERNAL_PATHto the destination path on your external HDD / SSD. -
Transfer photos and videos from iPhone / iPad to macOS using AirDrop. Files are usually saved in
~/Downloads. -
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.) -
Open Terminal and move to the directory containing the files.
-
Run
photo_mv.sh.
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.
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.)
Use of OpenStreetMap data requires proper attribution.
This tool records the license string (e.g. Data © OpenStreetMap contributors...)
in keyword.txt.
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).