Created
January 1, 2023 17:55
-
-
Save pasdam/b307b73af17fade880ecd3098b30c3fa to your computer and use it in GitHub Desktop.
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 | |
DIR=$1 | |
cd "$DIR" | |
for d in */ ; do | |
if [[ "$d" =~ .*\([0-9\-]+\).* ]]; then | |
date=$(echo $d | sed "s/.*(//" | sed "s/)\///") | |
new_name="$date - $(echo $d | sed "s/$date//" | sed "s/ ()//")" | |
if [ ! -d "$new_name" ]; then | |
mv "$d" "$new_name" | |
else | |
echo "Skipping $d as $new_name already exists" | |
fi | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment