Skip to main content

Rename, sort, and safely archive exported picture and video files.

Project description

PictureArchiver

Photos ライブラリなどから書き出した写真・動画をリネームし、archive/raw/ に安全に整理するためのツールです。

1. ディレクトリ構成

写真管理用の親ディレクトリを PA_ROOT と呼びます。指定しない場合は、parc を実行したカレントディレクトリが PA_ROOT になります。

PA_ROOT/
├── import/         # 書き出された処理対象ファイル
├── archive/        # アーカイブ出力先(年/年-月-日 の階層で保存)
├── raw/            # RAW ファイル出力先(拡張子ごとに分類)
├── .stage/         # 反映前の作業コピー
└── .backups/       # apply 時の退避先

2. 処理の例

import/ にあるファイルは、撮影日時から yyyymmdd_HHMMSS_mmm.ext 形式へリネームされます。 JPEG/HEIC/PNG/WebP/動画は archive/年/年-月-日/、RAW は raw/RAW形式/ に移動します。

例えば、次の 3 ファイルがすべて 2024-05-06 12:34:56.789 に撮影されたものだとします。

PA_ROOT/
├── import/
│   ├── IMG_0000.jpeg
│   ├── IMG_0001.heic
│   └── IMG_0000.cr2
├── archive/
└── raw/

parc stage で確認し、parc apply で反映すると次のようになります。

PA_ROOT/
├── import/                  # apply 後、中身はゴミ箱へ移動される
├── archive/
│   └── 2024/
│       └── 2024-05-06/
│           ├── 20240506_123456_789.jpeg
│           └── 20240506_123456_789.heic
└── raw/
    └── canon cr2/
        └── 20240506_123456_789.cr2

同じ日付の archive/2024/2024-05-06 イベント名/ のようなフォルダがすでにある場合は、新しく 2024-05-06/ を作らず、そのイベント名付きフォルダに追加します。

3. 使い方

1. 写真を書き出す

  1. 内蔵ライブラリを起動する
  2. 写真や動画をPA_ROOT/import/ に書き出す

2. ターミナルで実行する

# 初回のみ
pip install picture-archiver

# PA_ROOTに移動
cd /path/to/your/PA_ROOT

# 変更をステージして、差分を確認
parc stage

# 問題なければ適用
parc apply

parc 単体では使えるコマンド一覧を表示します。parc stage は作業コピーを作って整理処理を実行し、差分を表示します。parc apply は差分を反映し、上書き・削除される既存ファイルがあれば .backups/YYYYMMDD_HHMMSS/ に退避します。

4. Option

取り込みをやり直す

stage したあとで、取り込みたくない画像や修正したい内容が見つかった場合は、import/ を修正してから parc stage を再実行します。

完全にstageを作り直したい場合は --replace を使います。

parc stage --replace

ステージ後、即座に適用する

parc stage --apply

parc apply と同じ確認プロンプトが出ます。

ディレクトリを指定する

# import, archive, raw を含む親ディレクトリを一括指定する場合
export PA_ROOT=/path/to/pictures-root

# 個別にディレクトリを指定する場合
export PA_IMPORT_DIR=/path/to/import
export PA_ARCHIVE_DIR=/path/to/archive
export PA_RAW_DIR=/path/to/raw
export PA_STAGE_ROOT=/path/to/stage
export PA_BACKUP_ROOT=/path/to/backups

stageせずに直接実行する(非推奨)

python main.py を直接実行すると、import 内のファイルを archive raw へ直接移動します。上書きされる対象はバックアップされません。

python main.py

Photos ライブラリを統合する

iCloudに紐づいたPhotos ライブラリは、他のライブラリから読み込むことができませんが、複製は読み込むことができます。

  1. 内蔵ライブラリを複製する
  2. 統合先の Photos ライブラリを開き、ファイル > 読み込む で複製したライブラリを選択する
  3. 取り込む写真・動画を選択し、読み込む

主要ファイル

  • main.py: エントリーポイント
  • parc: どのディレクトリからでも実行するためのコマンド
  • pic_archiver.py: コア処理(日時抽出・リネーム・振り分け)
  • config.py: パス設定(デフォルトはこのリポジトリのディレクトリ、環境変数で上書き可)
  • *.sh: 作業コピーで確認してから反映するための一連のコマンド

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

picture_archiver-0.1.2.tar.gz (13.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

picture_archiver-0.1.2-py3-none-any.whl (12.5 kB view details)

Uploaded Python 3

File details

Details for the file picture_archiver-0.1.2.tar.gz.

File metadata

  • Download URL: picture_archiver-0.1.2.tar.gz
  • Upload date:
  • Size: 13.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for picture_archiver-0.1.2.tar.gz
Algorithm Hash digest
SHA256 06cdc9da2ea3e4432389971b99f5d5451870b4284766879959d9f4412a175b7d
MD5 57da8c701c8e4c54730356284a9b3f7c
BLAKE2b-256 0206916270727db0b47fa04686ace8da8f07fd88354e57b82ccdd28e43e1c395

See more details on using hashes here.

Provenance

The following attestation bundles were made for picture_archiver-0.1.2.tar.gz:

Publisher: publish.yml on Ryota-Nitto/PictureArchiver

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file picture_archiver-0.1.2-py3-none-any.whl.

File metadata

File hashes

Hashes for picture_archiver-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 bc98c8e92aea93b550ab8474fbe441dd3c25bc39667f49886a0acd7376b3b31b
MD5 f7b606acc8badf33d6da0e46bf8ccd24
BLAKE2b-256 8929b2ddc5a4a22ef3e1163c1b51bb116bf6e93bcee043fe48fd5626f9a87a4f

See more details on using hashes here.

Provenance

The following attestation bundles were made for picture_archiver-0.1.2-py3-none-any.whl:

Publisher: publish.yml on Ryota-Nitto/PictureArchiver

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page