AI作成 試してない

#!/bin/bash
# 移動元のフォルダーを指定
srcdir="/path/to/source"
# 移動先のフォルダーを指定
dstdir="/path/to/destination"
# 移動元のフォルダーの中のフォルダーをループで処理
for dir in "$srcdir"/*; do
# フォルダーでなければスキップ
if [ ! -d "$dir" ]; then
continue
fi
# フォルダーの中のファイルをループで処理
for file in "$dir"/*; do
# ファイル名と拡張子を取得
filename=$(basename "$file")
extension="${filename##*.}"
# 移動先のフォルダーに同じファイル名があるかチェック
if [ -f "$dstdir/$filename" ]; then
# 同じファイル名がある場合は、(1),(2)等の番号を付けて退避