-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
画像処理の並列化を実装し、
main.py
をリファクタリングしました。process_image
関数を簡素化し、`process_i…
…mages`関数を追加して、最初の画像を処理した後に残りの画像をスレッドプールで並列処理するように変更しました。また、最大ワーカー数を定義する定数`MAX_WORKERS`を追加しました。
- Loading branch information
Showing
2 changed files
with
49 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#!/bin/sh -eu | ||
|
||
echo "imagesディレクトリ内のjpgファイルを最適なファイル名にリネームします" | ||
echo "Enterで開始します" | ||
read dummy | ||
cd images | ||
for file in *.jpg; do | ||
if [ ! "$(echo "$file" | grep -E "^[0-9]{8}(_[0-9]{6}[a-z]{2})?\.jpg$")" ]; then | ||
random_suffix=$(cat /dev/urandom | tr -dc 'a-z' | fold -w 2 | head -n 1) | ||
new_name=$(date -r "$file" +%Y%m%d_%H%M%S${random_suffix}.jpg) | ||
|
||
echo "$file" "$new_name" | ||
mv "$file" "$new_name" | ||
fi | ||
done | ||
|
||
echo "完了しました" |