Last active
June 6, 2018 20:34
-
-
Save BenjaminLawson/ed1b352087147cc99547b6a8b9d385c2 to your computer and use it in GitHub Desktop.
Bash script to generate absolute m3u files
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 | |
# 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