Skip to content

Instantly share code, notes, and snippets.

@naogify
Last active September 20, 2024 22:41
Show Gist options
  • Save naogify/88bdb01d3ce79cbfff60ce9dd523b057 to your computer and use it in GitHub Desktop.
Save naogify/88bdb01d3ce79cbfff60ce9dd523b057 to your computer and use it in GitHub Desktop.
全てのShapeファイルをカレントディレクトリに移動する
#!/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