Skip to content

Instantly share code, notes, and snippets.

@plskz
Created March 13, 2024 07:13
Show Gist options
  • Save plskz/d594e26d74e02dd4dfb4ed0d4b195572 to your computer and use it in GitHub Desktop.
Save plskz/d594e26d74e02dd4dfb4ed0d4b195572 to your computer and use it in GitHub Desktop.
update folder name for my-threejs-journey repo
#!/bin/bash
# Target starting number for renaming (start at 64)
start_number=64
# Iterate through folders in reverse, starting with folder number 51
for i in {51..32}; do
old_name="${i}-" # Build the old folder name pattern
# Check if the folder exists
if [ -d "$old_name"* ]; then
folder_base_name=$(basename "$old_name"*) # Get just the base folder name
folder_base_name="${folder_base_name#*-}" # Remove the old number prefix
new_name="${start_number}-${folder_base_name}" # Build the new name
mv "$old_name"* "$new_name" # Perform the renaming
echo "Renamed $old_name to $new_name"
((start_number--)) # Decrement the target number
fi
done
@plskz
Copy link
Author

plskz commented Mar 13, 2024

  • chmod +x rename.sh
  • ./rename.sh

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment