Last active
September 11, 2024 01:41
-
-
Save naogify/5f94017ec9a515af6161f559144e118d to your computer and use it in GitHub Desktop.
# 再帰的にzipを解凍するコマンド
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
#!/usr/bin/env bash | |
set -ex | |
# 再帰的にzipを解凍する関数 | |
unzip_recursively() { | |
local target_dir=$1 | |
# 現在のディレクトリ内のすべてのzipファイルを探して解凍 | |
find "$target_dir" -name '*.zip' | while read zip_file; do | |
# 解凍する | |
unzip -u -O sjis "$zip_file" -d "${zip_file%.*}" | |
# 解凍後にzipファイルを削除 | |
rm "$zip_file" | |
# 解凍したディレクトリにさらにzipがあれば再帰的に解凍 | |
unzip_recursively "${zip_file%.*}" | |
done | |
} | |
unzip_recursively . |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment