Last active
September 20, 2024 22:41
-
-
Save naogify/88bdb01d3ce79cbfff60ce9dd523b057 to your computer and use it in GitHub Desktop.
全てのShapeファイルをカレントディレクトリに移動する
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 | |
# 対象とする拡張子のリスト(小文字・大文字両方を許容) | |
extensions=("shp" "prj" "cpg" "dbf" "sbn" "fbn" "ain" "ixs" "mxs" "atx" "shp.xml" "shx" "mxd" "geojson") | |
# 各拡張子についてファイルを検索し、カレントディレクトリに移動する | |
for ext in "${extensions[@]}"; do | |
find . -type f -iname "*.$ext" -exec bash -c ' | |
target="./$(basename "$1")" | |
if [ -e "$target" ]; then | |
echo "$target already exists, skipping mv." | |
else | |
mv "$1" ./ | |
fi | |
' _ {} \; | |
done | |
echo "すべての関連ファイルをカレントディレクトリに移動しました(重複ファイルは移動されませんでした)。" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment