Skip to content

Commit 2fe3e19

Browse files
authored
Merge pull request #1 from diy-turtle/v1
v1.0.0
2 parents b269d23 + 87473c2 commit 2fe3e19

File tree

4 files changed

+140
-1
lines changed

4 files changed

+140
-1
lines changed

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
user_content/
2+
src/__pycache__

README.md

+80-1
Original file line numberDiff line numberDiff line change
@@ -1 +1,80 @@
1-
# PhotoSort-Lite
1+
# PhotoSort-Lite
2+
![GitHub License](https://img.shields.io/github/license/diy-turtle/PhotoSort-Lite)
3+
![GitHub top language](https://img.shields.io/github/languages/top/diy-turtle/PhotoSort-Lite)
4+
![GitHub Release](https://img.shields.io/github/v/release/diy-turtle/PhotoSort-Lite)
5+
6+
軽量版写真・動画リネームソフト
7+
8+
![ver1_0_0 - スクリーンショット](https://github.com/diy-turtle/PhotoSort-Lite/assets/163115290/fa63b1c4-4920-43a0-b2f0-bd5029c165c9)
9+
10+
## 主な機能
11+
- 軽量で高速な動作
12+
- 撮影日時によるリネーム (Unix 時間)
13+
14+
## 使い方
15+
### 1. **ファイルのダウンロードまたはクローン**
16+
以下のいずれかの方法で、PhotoSort-Lite ソフトウェアを自分のPCにダウンロードしてください。
17+
- ダウンロード
18+
- **https://github.com/diy-turtle/PhotoSort-Lite.git** から最新版のZIPファイルをダウンロードし、解凍します。
19+
- クローン
20+
- ターミナルまたはGit GUIツールを使って、以下のコマンドを実行します。
21+
```
22+
git clone https://github.com/diy-turtle/PhotoSort-Lite
23+
```
24+
25+
26+
### 2. **config.json ファイルの作成**
27+
28+
config.jsonファイルは、PhotoSort-Liteの設定を保存するファイルです。以下の内容を参考に、config.jsonファイルを作成してください。ファイルは、 ./user_content/ に保存してください。
29+
30+
#### config.json
31+
```json
32+
{
33+
"version": "1.0.0",
34+
"type": "lite",
35+
"folder": "./user_content/upload/",
36+
"extensions": ["jpg", "gif", "png", "mov"]
37+
}
38+
```
39+
40+
#### config.jsonの詳細
41+
| キー | 内容 | 必須 | 規定値 |
42+
| --- | --- | --- | --- |
43+
| version | config.json が作成されたときの PhotoSort-Lite のバージョン | はい | 1.0.0 |
44+
| type | プログラムのタイプ | はい | lite |
45+
| folder | PhotoSort-Lite でリネームする写真があるフォルダ | はい | ./user_content/upload/ |
46+
| extensions | リネームするファイルの拡張子 | はい | jpg, gif, png, mov |
47+
48+
### 3. プログラムの実行
49+
./src/main.py を実行してください。
50+
```
51+
python main.py
52+
```
53+
54+
> [!NOTE]
55+
> #### プログラムの役割
56+
> | ファイル名 | 役割 |
57+
> | --- | --- |
58+
> | ./src/main.py | 他のプログラムの実行や GUI 画面の作成 |
59+
> | ./src/sort.py | 写真を並び替え |
60+
61+
62+
## 使用したライブラリ
63+
### メインプログラム (main.py)
64+
- json (https://jsons.readthedocs.io/) (Apache License 2.0)
65+
66+
JSON データの読み書き
67+
- tkinter (https://docs.python.org/3/library/tkinter.html) (Python Software Foundation License)
68+
69+
Tkinter GUI ツールキット
70+
- sort (自作モジュール)
71+
72+
73+
### サブモジュール (sort.py)
74+
- os (https://docs.python.org/3/library/os.html) (標準ライブラリ)
75+
76+
オペレーティングシステムとのやり取り
77+
78+
- json (https://jsons.readthedocs.io/) (Apache License 2.0)
79+
80+
JSON データの読み書き

src/main.py

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import json
2+
import tkinter as tk
3+
import sort
4+
5+
# 設定ファイルの読み込み
6+
with open("../user_content/config.json") as config_json:
7+
config_data = json.load(config_json)
8+
9+
# ウィンドウの作成
10+
root = tk.Tk()
11+
root.title("PhotoSort-Lite (ver1.0.0)")
12+
13+
# フォルダ名
14+
folder = tk.Label(root, text="フォルダ :" + config_data["folder"])
15+
folder.pack()
16+
17+
# 適応ボタン
18+
apply_btn = tk.Button(root, text="適応", command=sort.PhotoSort_lite)
19+
apply_btn.pack()
20+
21+
# 対応する拡張子
22+
file_extensions = tk.Label(root, text="対応する拡張子 :" + str(config_data["extensions"]))
23+
file_extensions.pack()
24+
25+
# ライセンス
26+
license = tk.Label(root, text="MIT License")
27+
license.pack()
28+
29+
root.mainloop()

src/sort.py

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import os
2+
import json
3+
4+
# 設定ファイルの読み込み
5+
with open("../user_content/config.json") as config_json:
6+
config_data = json.load(config_json)
7+
8+
# 拡張子が含まれているかを調べるプログラム
9+
def is_include(filename):
10+
file_extensions = config_data["extensions"]
11+
for i in range(len(file_extensions)):
12+
if filename.lower().find(file_extensions[i]) != -1:
13+
return file_extensions[i]
14+
return False
15+
16+
# 写真を並べ替えるプログラム
17+
def PhotoSort_lite():
18+
file_name_list = os.listdir(config_data["folder"])
19+
20+
# 画像、動画ファイルのリネーム
21+
for i in range(len(file_name_list)):
22+
file_pass = config_data["folder"] + file_name_list[i]
23+
if is_include(file_name_list[i]) != False:
24+
print("リネーム後のファイル名 :" + file_name_list[i])
25+
took_time = os.stat(file_pass).st_ctime
26+
os.rename(file_pass, config_data["folder"] + str(took_time).replace(".", "") + "." + is_include(file_name_list[i]))
27+
28+
print("完了しました")
29+
return "finish"

0 commit comments

Comments
 (0)