Files
bin/categorize
rozbrian 304cbcc554 update
2026-01-10 20:46:22 +09:00

29 lines
928 B
Bash
Executable File

#!/bin/bash
# Find directories in the current directory and process each one
find . -maxdepth 1 -type d -print0 | while IFS= read -r -d '' dir; do
if [[ "$dir" != "." ]]; then
# Extract the old directory name, stripping leading './'
OLDNAME="${dir:2}"
echo "==== $OLDNAME ===="
# Generate the new directory name
NEWNAME=$(echo "$OLDNAME" | awk -F'시즌[0-9]' '{ print $1 }')
if [[ "$OLDNAME" == "$NEWNAME" ]]; then
echo "\"$OLDNAME\" ok!"
else
echo "\"$OLDNAME\" -> \"$NEWNAME\""
# Ensure the new directory does not already exist to avoid overwriting
if [[ ! -d "$NEWNAME" ]]; then
sudo mkdir "$NEWNAME"
sudo mv "$dir" "$NEWNAME"
else
echo "\"$NEWNAME\" already exists, skipping move $OLDNAME"
fi
fi
fi
done