Skip to content

Instantly share code, notes, and snippets.

@pjobson
Created January 31, 2026 05:36
Show Gist options
  • Select an option

  • Save pjobson/1bcf414fb1e5c3019e72bffce02e416e to your computer and use it in GitHub Desktop.

Select an option

Save pjobson/1bcf414fb1e5c3019e72bffce02e416e to your computer and use it in GitHub Desktop.
#!/bin/bash
SRC_DIR="$1"
DEST_DIR="$2"
if [ -z "$SRC_DIR" ] || [ -z "$DEST_DIR" ]; then
echo "Usage: $0 <source_dir> <dest_dir>"
exit 1
fi
mkdir -p "$DEST_DIR"
find "$SRC_DIR" -type f -name "*.mp3" -print0 |
while IFS= read -r -d '' file; do
RAND_STR=$(head -c 500 /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 8 | head -n 1)
FILENAME=$(basename "$file")
cp "$file" "$DEST_DIR/${RAND_STR} - ${FILENAME}"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment