Skip to content

Instantly share code, notes, and snippets.

@BenjaminLawson
Last active June 6, 2018 20:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save BenjaminLawson/ed1b352087147cc99547b6a8b9d385c2 to your computer and use it in GitHub Desktop.
Save BenjaminLawson/ed1b352087147cc99547b6a8b9d385c2 to your computer and use it in GitHub Desktop.
Bash script to generate absolute m3u files
#!/usr/bin/env bash
# Usage: m3u-absolutify playlists_dir output_dir /absolute/path/to/music
# Description: generates absolute path versions of all m3u files in a directory
# Author: Ben Lawson
SOURCE_DIR=$1
DEST_DIR=$2
ABSOLUTE_MUSIC_DIR=$3
# create DEST_DIR if it doesn't already exist
mkdir -p "$DEST_DIR"
for file in "$SOURCE_DIR"/*.m3u; do
echo "Processing: $file"
name=${file##*/}
# delete comments & prefix music dir path
sed -e "/^#/d" -e "s#^#$ABSOLUTE_MUSIC_DIR#" "$file" > "$DEST_DIR/$name"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment