Skip to content

Instantly share code, notes, and snippets.

@mattpetters
Created November 6, 2023 06:56
Show Gist options
  • Save mattpetters/f3fccac80683a4526539b4cb8710d158 to your computer and use it in GitHub Desktop.
Save mattpetters/f3fccac80683a4526539b4cb8710d158 to your computer and use it in GitHub Desktop.
Script to remove prefixes from Ableton stem exports -- usage: ./rename_stems.sh "MY_PROJECT PREFIX ABCDEF"
#!/bin/zsh
# Check if an argument was provided
if [ $# -eq 0 ]; then
echo "Usage: $0 prefix"
exit 1
fi
# Prefix to be removed (first argument)
PREFIX="$1"
# Store the directory where the script is located
SCRIPT_DIR=$(dirname "$0")
# Change to the directory where the script is located
cd "$SCRIPT_DIR" || exit
# Loop through all .wav files with the specified prefix
for file in ${PREFIX}*.wav; do
# Remove the prefix from the file name
newname="${file#${PREFIX}}"
# Rename the file
mv -- "$file" "$newname"
done
echo "Renaming complete."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment